pub struct PopupContent<A> { /* private fields */ }Expand description
Retained factory used to remount popup content in either an overlay tree or a native presentation.
The UI-thread-local Rc makes clones share one factory without requiring
Send or Sync. Each Self::build invocation calls the factory again and
returns a fresh declarative view.
§Examples
use ailloli_ui_runtime::{component::View, popup::PopupContent};
let content = PopupContent::<()>::new(|| View::empty().key("menu"));
assert_eq!(content.build().key_ref(), Some("menu"));Implementations§
Source§impl<A> PopupContent<A>
Factory construction and invocation.
impl<A> PopupContent<A>
Factory construction and invocation.
Sourcepub fn new(factory: impl Fn() -> View<A> + 'static) -> Self
pub fn new(factory: impl Fn() -> View<A> + 'static) -> Self
Stores a UI-thread-local 'static view factory without invoking it.
§Examples
use std::{cell::Cell, rc::Rc}; use ailloli_ui_runtime::{component::View, popup::PopupContent};
let calls = Rc::new(Cell::new(0)); let seen = calls.clone();
let content = PopupContent::<()>::new(move || { seen.set(seen.get() + 1); View::empty() });
assert_eq!(calls.get(), 0); content.build(); assert_eq!(calls.get(), 1);Trait Implementations§
Source§impl<A> Clone for PopupContent<A>
Clones the shared factory rather than invoking or duplicating it.
impl<A> Clone for PopupContent<A>
Clones the shared factory rather than invoking or duplicating it.
Auto Trait Implementations§
impl<A> Freeze for PopupContent<A>
impl<A> !RefUnwindSafe for PopupContent<A>
impl<A> !Send for PopupContent<A>
impl<A> !Sync for PopupContent<A>
impl<A> Unpin for PopupContent<A>
impl<A> !UnwindSafe for PopupContent<A>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
Source§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.