Struct dioxus_core::scope::Scope[][src]

pub struct Scope {
    pub hooks: RefCell<Vec<*mut Hook>>,
    pub hook_arena: Arena<Hook>,
    pub parent: Option<Index>,
    pub frames: ActiveFrame,
    pub listeners: Vec<*const dyn Fn(VirtualEvent)>,
    pub props: Box<dyn Any>,
    pub caller: *const (),
}

Every component in Dioxus is represented by a Scope.

Scopes contain the state for hooks, the component’s props, and other lifecycle information.

Scopes are allocated in a generational arena. As components are mounted/unmounted, they will replace slots of dead components. The actual contents of the hooks, though, will be allocated with the standard allocator. These should not allocate as frequently.

Fields

hooks: RefCell<Vec<*mut Hook>>hook_arena: Arena<Hook>parent: Option<Index>frames: ActiveFramelisteners: Vec<*const dyn Fn(VirtualEvent)>props: Box<dyn Any>caller: *const ()

Implementations

impl Scope[src]

pub fn new<'a, P1, P2: 'static>(
    f: FC<P1>,
    props: P1,
    parent: Option<Index>
) -> Self
[src]

pub fn run<'bump, PLocked: Sized + 'static>(&'bump mut self)[src]

Create a new context and run the component with references from the Virtual Dom This function downcasts the function pointer based on the stored props_type

Props is ?Sized because we borrow the props and don’t need to know the size. P (sized) is used as a marker (unsized)

pub fn new_frame<'bump>(&'bump self) -> &'bump VNode<'bump>[src]

Accessor to get the root node and its children (safely)
Scope is self-referntial, so we are forced to use the ’static lifetime to cheat

pub fn old_frame<'bump>(&'bump self) -> &'bump VNode<'bump>[src]

Auto Trait Implementations

impl !RefUnwindSafe for Scope

impl !Send for Scope

impl !Sync for Scope

impl Unpin for Scope

impl !UnwindSafe for Scope

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.