pub struct Owner { /* private fields */ }Expand description
Owns every signal, memo, effect and child owner created through it, and frees them all when it is disposed.
Each widget opens one, and dropping the widget disposes it.
crabshell-ui’s Cx wraps an Owner. Get a root owner from
Runtime::new_owner and nested ones from
child.
Implementations§
Source§impl Owner
impl Owner
Sourcepub fn child(&self) -> Owner
pub fn child(&self) -> Owner
Creates an owner inside this one. Disposing this owner disposes the child too.
§Panics
This and the other create methods panic if this owner was disposed.
Sourcepub fn memo<T: PartialEq + 'static>(
&self,
f: impl FnMut() -> T + 'static,
) -> Memo<T>
pub fn memo<T: PartialEq + 'static>( &self, f: impl FnMut() -> T + 'static, ) -> Memo<T>
Creates a Memo that derives its value with f. f first runs
when something reads the memo.
Sourcepub fn effect_scoped(&self, f: impl FnMut(Owner) + 'static) -> Effect
pub fn effect_scoped(&self, f: impl FnMut(Owner) + 'static) -> Effect
Like effect, for an effect that builds things on
every run, such as a list’s child widgets.
Each run gets a fresh owner, scope, to create them under. The scope
belongs to the effect itself: before the next run, the previous scope
is disposed with everything in it, and when the effect stops, its
last scope goes with it. The effect stops when this owner is
disposed, or when it is disabled after a panic or a dependency cycle.
Sourcepub fn is_disposed(&self) -> bool
pub fn is_disposed(&self) -> bool
Whether this owner was disposed, itself or with its parent, so code that may outlive its context can check before it creates anything under it, which would panic.