Skip to main content

Scope

Struct Scope 

Source
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: bool

When 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.

Implementations§

Source§

impl Scope

Source

pub fn new(parent: Option<Owner>) -> Self

Auto Trait Implementations§

§

impl !RefUnwindSafe for Scope

§

impl !Send for Scope

§

impl !Sync for Scope

§

impl !UnwindSafe for Scope

§

impl Freeze for Scope

§

impl Unpin for Scope

§

impl UnsafeUnpin for Scope

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.