Struct freya::prelude::ReactiveContext
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 associated contexts attached to signal
Implementations§
§impl ReactiveContext
impl ReactiveContext
pub fn new() -> (ReactiveContext, UnboundedReceiver<()>)
pub fn new() -> (ReactiveContext, UnboundedReceiver<()>)
Create a new reactive context
pub 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
pub 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
pub 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.
pub 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.
pub 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
pub fn origin_scope(&self) -> ScopeId
pub fn origin_scope(&self) -> ScopeId
Get the scope that inner CopyValue is associated with
Trait Implementations§
§impl Clone for ReactiveContext
impl Clone for ReactiveContext
§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 more§impl Display for ReactiveContext
impl Display for ReactiveContext
§impl Hash for ReactiveContext
impl Hash for ReactiveContext
§impl PartialEq for ReactiveContext
impl PartialEq for ReactiveContext
§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
§impl<T> CallHasher for T
impl<T> CallHasher for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more