Struct rustcn_ui::ReactiveContext 
source · pub struct ReactiveContext { /* private fields */ }Expand description
A context for signal reads and writes to be directed to
When a signal calls .read(), it will look for the current ReactiveContext to read from. If it doesn’t find it, then it will try and insert a context into the nearest component scope via context api.
When the ReactiveContext drops, it will remove itself from the the associated contexts attached to signal
Implementations§
source§impl ReactiveContext
 
impl ReactiveContext
sourcepub fn new() -> ReactiveContext
 
pub fn new() -> ReactiveContext
Create a new reactive context
sourcepub fn current() -> Option<ReactiveContext>
 
pub fn current() -> Option<ReactiveContext>
Get the current reactive context
If this was set manually, then that value will be returned.
If there’s no current reactive context, then a new one will be created for the current scope and returned.
sourcepub fn run_in<O>(&self, f: impl FnOnce() -> O) -> O
 
pub fn run_in<O>(&self, f: impl FnOnce() -> O) -> O
Run this function in the context of this reactive context
This will set the current reactive context to this context for the duration of the function. You can then get information about the current subscriptions.
sourcepub fn mark_dirty(&self) -> bool
 
pub fn mark_dirty(&self) -> bool
Marks this reactive context as dirty
If there’s a scope associated with this context, then it will be marked as dirty too
Returns true if the context was marked as dirty, or false if the context has been dropped
sourcepub fn origin_scope(&self) -> ScopeId
 
pub fn origin_scope(&self) -> ScopeId
Get the scope that inner CopyValue is associated with
Trait Implementations§
source§impl Clone for ReactiveContext
 
impl Clone for ReactiveContext
source§fn clone(&self) -> ReactiveContext
 
fn clone(&self) -> ReactiveContext
1.0.0 · source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Default for ReactiveContext
 
impl Default for ReactiveContext
source§fn default() -> ReactiveContext
 
fn default() -> ReactiveContext
source§impl Hash for ReactiveContext
 
impl Hash for ReactiveContext
source§impl PartialEq for ReactiveContext
 
impl PartialEq for ReactiveContext
source§fn eq(&self, other: &ReactiveContext) -> bool
 
fn eq(&self, other: &ReactiveContext) -> bool
self and other values to be equal, and is used
by ==.