[−][src]Struct reactive_state::Callback
A wrapper for a callback which is notified of changes to
Store State, and Events produced by the store.
Example
The following example makes use of the AsListener
trait implementation for Callback which allows it to be used in
Store::subscribe(). The
AsListener trait creates a weak reference to this
callback in a Listener, which is given to the
Store. When the callback is dropped, the listener will be
removed from the store.
use reactive_state::Callback; let callback = Callback::new(|_state, _event| { println!("Callback invoked"); }); store.subscribe(&callback);
Optional Features
If the "yew" crate feature is enabled, a number of From
implementations are available to convert yew callbacks into
this:
From<yew::Callback<Rc<State>>>From<yew::Callback<(Rc<State>, Event)>>From<yew::Callback<()>>
Implementations
impl<State, Event> Callback<State, Event>[src]
pub fn new<C: Fn(Rc<State>, Event) + 'static>(closure: C) -> Self[src]
pub fn emit(&self, state: Rc<State>, event: Event)[src]
Trait Implementations
impl<State, Event, '_> AsListener<State, Event> for &'_ Callback<State, Event>[src]
fn as_listener(&self) -> Listener<State, Event>[src]
impl<State: Clone, Event: Clone> Clone for Callback<State, Event>[src]
impl<C, State, Event> From<C> for Callback<State, Event> where
C: Fn(Rc<State>, Event) + 'static, [src]
C: Fn(Rc<State>, Event) + 'static,
impl<State, Event> From<Callback<()>> for Callback<State, Event> where
State: 'static,
Event: 'static, [src]
State: 'static,
Event: 'static,
impl<State, Event> From<Callback<(Rc<State>, Event)>> for Callback<State, Event> where
State: 'static,
Event: 'static, [src]
State: 'static,
Event: 'static,
impl<State, Event> From<Callback<Rc<State>>> for Callback<State, Event> where
State: 'static,
Event: 'static, [src]
State: 'static,
Event: 'static,
Auto Trait Implementations
impl<State, Event> !RefUnwindSafe for Callback<State, Event>
impl<State, Event> !Send for Callback<State, Event>
impl<State, Event> !Sync for Callback<State, Event>
impl<State, Event> Unpin for Callback<State, Event>
impl<State, Event> !UnwindSafe for Callback<State, Event>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> CloneAny for T where
T: Clone + Any,
T: Clone + Any,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,