pub struct Scope {
pub parent: Option<Owner>,
pub children: Vec<Owner>,
pub nodes: Vec<NodeId>,
pub contexts: HashMap<TypeId, Rc<dyn Any>>,
pub cleanups: Vec<Box<dyn FnOnce()>>,
pub mount_fn: Option<*const ()>,
pub elements: Vec<Element>,
pub paused: bool,
}Expand description
A scope record in the reactive tree. Created when a component mounts, disposed when the component unmounts. Tracks the reactive nodes allocated inside it (so they can be freed on disposal) and the child scopes (so disposal cascades).
The public-facing API surface is the [super::owner::Owner]
handle (a Copy slotmap key); Scope is the data record that
handle dereferences to via the runtime’s owners slotmap. Users
(and even framework extension authors) never name Scope
directly.
contexts is the per-scope context bag for provide_context /
use_context. cleanups is the LIFO callback queue from
on_cleanup.
Fields§
§parent: Option<Owner>§children: Vec<Owner>§nodes: Vec<NodeId>§contexts: HashMap<TypeId, Rc<dyn Any>>§cleanups: Vec<Box<dyn FnOnce()>>§mount_fn: Option<*const ()>Function-pointer fingerprint of the component fn that created
this scope. Used by Strategy C hot reload (A6) to map
subsecond-patched fn pointers back to live owners. None for
non-component scopes (e.g. the root, or manually-created
scopes in tests).
elements: Vec<Element>Element handles created via view::create_element while this
scope was at the top of the owner stack. Released through
view::release_element when the scope is disposed (or its
ancestor disposes via cascade), preventing the renderer-side
BridgeRenderer::elements map from accumulating dangling
WhiskerElement* pointers across <Show> flips, <For>
item removals, and per-component remounts.
paused: boolWhen true, effects / computeds owned by this scope skip
flush — they’re deferred onto ReactiveRuntime::deferred
until the owner is resumed.
Cascades down the owner tree: Owner::pause / Owner::resume
walk descendants and mirror the flag; new scopes inherit the
parent’s flag at Owner::new time. Used by StackLayout
to freeze back-stack entries that are mounted-but-off-screen.