[−][src]Struct reactive_state::StoreRef
A wrapper for an Rc reference to a Store.
This wrapper exists to provide a standard interface for re-useable
middleware and other components which may require a long living
reference to the store in order to dispatch actions or modify it
in some manner that could not be handled by a simple &Store.
Implementations
impl<State, Action, Event, Effect> StoreRef<State, Action, Event, Effect> where
Event: StoreEvent + Clone + Hash + Eq, [src]
Event: StoreEvent + Clone + Hash + Eq,
pub fn new<R: Reducer<State, Action, Event, Effect> + 'static>(
reducer: R,
initial_state: State
) -> Self[src]
reducer: R,
initial_state: State
) -> Self
Methods from Deref<Target = Store<State, Action, Event, Effect>>
pub fn state(&self) -> Rc<State>[src]
Get the current State stored in this store.
Modifications to this state need to be performed by
dispatching an Action to the store using
dispatch().
pub fn dispatch<A: Into<Action>>(&self, action: A)[src]
Dispatch an Action to be passed to the Reducer in order to
modify the State in this store, and produce Events to be
sent to the store listeners.
pub fn subscribe<L: AsListener<State, Event>>(&self, listener: L)[src]
Subscribe a Listener to changes in the store state and
events produced by the Reducer as a result of Actions
dispatched via dispatch().
The listener is a weak reference; when the strong reference associated with it (usually Callback) is dropped, the listener will be removed from this store upon dispatch().
If you want to subscribe to state changes associated with
specific Events, see
subscribe_event() or
subscribe_event()
pub fn subscribe_event<L: AsListener<State, Event>>(
&self,
listener: L,
event: Event
)[src]
&self,
listener: L,
event: Event
)
Subscribe a Listener to changes in the store state and
events produced by the Reducer as a result of Actions
being dispatched via dispatch() and
reduced with the store's Reducer. This subscription is only
active changes which produce the specific matching event
from the Reducer.
The listener is a weak reference; when the strong reference associated with it (usually Callback) is dropped, the listener will be removed from this store upon dispatch().
pub fn subscribe_events<L: AsListener<State, Event>, E: IntoIterator<Item = Event>>(
&self,
listener: L,
events: E
)[src]
&self,
listener: L,
events: E
)
Subscribe a Listener to changes in the store state and
events produced by the Reducer as a result of Actions
being dispatched via dispatch() and
reduced with the store's Reducer. This subscription is only
active changes which produce any of the specific matching
events from the Reducer.
The listener is a weak reference; when the strong reference associated with it (usually Callback) is dropped, the listener will be removed from this store upon dispatch().
pub fn add_middleware<M: Middleware<State, Action, Event, Effect> + 'static>(
&self,
middleware: M
)[src]
&self,
middleware: M
)
Add Middleware to modify the behaviour of this Store during a dispatch().
Trait Implementations
impl<State, Action, Event, Effect> Clone for StoreRef<State, Action, Event, Effect>[src]
fn clone(&self) -> Self[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<State, Action, Event, Effect> Deref for StoreRef<State, Action, Event, Effect>[src]
type Target = Store<State, Action, Event, Effect>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target[src]
impl<State, Action, Event, Effect> PartialEq<StoreRef<State, Action, Event, Effect>> for StoreRef<State, Action, Event, Effect>[src]
Auto Trait Implementations
impl<State, Action, Event, Effect> !RefUnwindSafe for StoreRef<State, Action, Event, Effect>
impl<State, Action, Event, Effect> !Send for StoreRef<State, Action, Event, Effect>
impl<State, Action, Event, Effect> !Sync for StoreRef<State, Action, Event, Effect>
impl<State, Action, Event, Effect> Unpin for StoreRef<State, Action, Event, Effect>
impl<State, Action, Event, Effect> !UnwindSafe for StoreRef<State, Action, Event, Effect>
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>,