pub trait StoreApi<State, Action> where
    Action: Send + 'static,
    State: Send + 'static, 
{ fn dispatch<'life0, 'async_trait>(
        &'life0 self,
        action: Action
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn select<'life0, 'async_trait, S: Selector<State, Result = Result>, Result>(
        &'life0 self,
        selector: S
    ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
    where
        S: Selector<State, Result = Result> + Send + 'static,
        Result: Send + 'static,
        S: 'async_trait,
        Result: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
fn subscribe<'life0, 'async_trait, S: Subscriber<State> + Send + 'static>(
        &'life0 self,
        subscriber: S
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
    where
        S: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
; fn state_cloned<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = State> + Send + 'async_trait>>
    where
        State: Clone,
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... } }
Expand description

The store api offers an abstraction around all store functionality.

Both Store and StoreWithMiddleware implement StoreApi. This enables us to wrap multiple middlewares around each other.

Required methods

Dispatch a new action to the store

Notice that this method takes &self and not &mut self, this enables us to dispatch actions from multiple places at once without requiring locks.

Select a part of the state, this is more efficient than copying the entire state all the time. In case you still need a full copy of the state, use the state_cloned method.

Subscribe to state changes. Every time an action is dispatched the subscriber will be notified after the state is updated

Provided methods

Returns a cloned version of the state. This is not efficient, if you only need a part of the state use select instead

Implementors