pub struct Context { /* private fields */ }
Expand description
Execution context for a dispatch
Example
use yewdux::prelude::*;
#[derive(Clone, PartialEq, Default, Store)]
struct Counter(usize);
let cx = yewdux::Context::new();
let dispatch = Dispatch::<Counter>::new(&cx);
Implementations§
source§impl Context
impl Context
pub fn new() -> Self
pub fn global() -> Self
pub fn reduce<S: Store, R: Reducer<S>>(&self, r: R)
pub fn reduce_mut<S: Store + Clone, F: FnOnce(&mut S)>(&self, f: F)
sourcepub fn notify_subscribers<S: Store>(&self, state: Rc<S>)
pub fn notify_subscribers<S: Store>(&self, state: Rc<S>)
Send state to all subscribers.
sourcepub fn subscribe<S: Store, N: Callable<S>>(
&self,
on_change: N
) -> SubscriberId<S>
pub fn subscribe<S: Store, N: Callable<S>>( &self, on_change: N ) -> SubscriberId<S>
Subscribe to a store. on_change
is called immediately, then every time state changes.
sourcepub fn subscribe_silent<S: Store, N: Callable<S>>(
&self,
on_change: N
) -> SubscriberId<S>
pub fn subscribe_silent<S: Store, N: Callable<S>>( &self, on_change: N ) -> SubscriberId<S>
Similar to Self::subscribe, however state is not called immediately.
Trait Implementations§
source§impl PartialEq for Context
impl PartialEq for Context
impl StructuralPartialEq for Context
Auto Trait Implementations§
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
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
Mutably borrows from an owned value. Read more
§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> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self
to a value of a Properties
struct.source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self
to a value of a Properties
struct.