pub struct Owner(/* private fields */);Expand description
Identifier for an Owner slot in the runtime’s owner map.
Generational — disposing an owner invalidates outstanding
Owners pointing at the same slot index.
Implementations§
Source§impl Owner
impl Owner
Sourcepub fn new(parent: Option<Owner>) -> Owner
pub fn new(parent: Option<Owner>) -> Owner
Create a new owner. If parent is None the current
top-of-stack owner is used (or the owner becomes a root if
the stack is empty).
The new owner inherits its parent’s paused flag — so a
sub-component mounted while its containing route is
suspended starts paused, and its effects won’t fire until
the route resumes.
Sourcepub fn detached_root() -> Owner
pub fn detached_root() -> Owner
Create a parentless root owner, ignoring whatever owner is currently on the stack.
Unlike Owner::new(None) — which adopts the
current top-of-stack owner as parent — this always produces a
detached root. Use it for process-global singletons whose
lifetime must not be tied to the (possibly short-lived) owner
that happens to be active when the singleton is first touched.
The canonical case is a module that lazily mints an
arena-backed handle on first access (e.g.
whisker-safe-area): if that first access lands inside a
per-route / per-component owner, minting under new(None) would
free the handle when that scope disposes, and a later read would
hit a disposed node. Minting under a detached_root() (then
never disposing it) keeps the handle alive for the whole
process — the intended semantics for a singleton.
The returned owner is never auto-disposed; the caller is
expected to leak it (i.e. drop the handle without calling
dispose) for genuine process-lifetime data.
Sourcepub fn with<R>(self, f: impl FnOnce() -> R) -> R
pub fn with<R>(self, f: impl FnOnce() -> R) -> R
Push self as the current scope, run f, pop back.
Reactive primitives (signal(), effect(), computed(),
view elements created via render!) allocated inside f
will belong to this owner.
Sourcepub fn dispose(self)
pub fn dispose(self)
Dispose self, freeing all its descendants, nodes, and
running its cleanup callbacks.
Recursive — disposes children first, then this owner. Safe to call even if the owner has already been disposed (no-op).
Sourcepub fn pause(self)
pub fn pause(self)
Pause self (and its descendants): effects and computeds
whose scope is the paused subtree skip flush. Their
scheduled re-runs land on the runtime’s deferred list
until Owner::resume drains them back.
Idempotent — pausing an already-paused owner is a no-op.
The cascade walks the children tree breadth-first; new
descendants created while paused inherit the flag via
Owner::new.
Used by StackLayout to freeze back-stack entries that are
mounted-but-off-screen, matching iOS
UINavigationController / Android Fragment back-stack
semantics: state survives but no CPU is spent on
signal-driven re-renders behind the top route.
Sourcepub fn resume(self)
pub fn resume(self)
Resume self (and its descendants): clear the paused flag
and move any of its deferred effects back onto the pending
queue so they fire on the next flush.
Idempotent. Iterates super::runtime::ReactiveRuntime::deferred
and re-queues every node whose owner is no longer paused —
including descendants resumed by this cascade, and any
deferred node whose owner happens to have been unpaused by
an earlier call.
Trait Implementations§
impl Copy for Owner
impl Eq for Owner
Source§impl Key for Owner
impl Key for Owner
Source§fn null() -> Self
fn null() -> Self
new_key_type!, which calls this
method). Read more