Struct dioxus::prelude::ReactiveContext
source · pub struct ReactiveContext { /* private fields */ }
signals
only.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 associated contexts attached to signal
Implementations§
source§impl ReactiveContext
impl ReactiveContext
sourcepub fn new() -> (ReactiveContext, UnboundedReceiver<()>)
pub fn new() -> (ReactiveContext, UnboundedReceiver<()>)
Create a new reactive context
sourcepub fn new_with_origin(
origin: &'static Location<'static>
) -> (ReactiveContext, UnboundedReceiver<()>)
pub fn new_with_origin( origin: &'static Location<'static> ) -> (ReactiveContext, UnboundedReceiver<()>)
Create a new reactive context with a location for debugging purposes This is useful for reactive contexts created within closures
sourcepub fn new_with_callback(
callback: impl FnMut() + Send + Sync + 'static,
scope: ScopeId,
origin: &'static Location<'static>
) -> ReactiveContext
pub fn new_with_callback( callback: impl FnMut() + Send + Sync + 'static, scope: ScopeId, origin: &'static Location<'static> ) -> ReactiveContext
Create a new reactive context that may update a scope. When any signal that this context subscribes to changes, the callback will be run
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 Display for ReactiveContext
impl Display for 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 ==
.impl Copy for ReactiveContext
impl Eq for ReactiveContext
impl StructuralPartialEq for ReactiveContext
Auto Trait Implementations§
impl Freeze for ReactiveContext
impl !RefUnwindSafe for ReactiveContext
impl Send for ReactiveContext
impl Sync for ReactiveContext
impl Unpin for ReactiveContext
impl !UnwindSafe for ReactiveContext
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
source§fn super_into(self) -> O
fn super_into(self) -> O
source§impl<Cfg> TryIntoConfig for Cfg
impl<Cfg> TryIntoConfig for Cfg
source§fn into_config(self) -> Option<Cfg>
fn into_config(self) -> Option<Cfg>
launch
only.