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 the associated contexts attached to signal
Implementations§
§impl ReactiveContext
impl ReactiveContext
pub fn new() -> ReactiveContext
pub fn new() -> ReactiveContext
Create a new reactive context
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
pub async fn changed(&self)
pub async fn changed(&self)
Wait for this reactive context to change
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 Default for ReactiveContext
impl Default for ReactiveContext
§fn default() -> ReactiveContext
fn default() -> 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 StructuralEq for ReactiveContext
impl StructuralPartialEq for ReactiveContext
Auto Trait Implementations§
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>
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.