Struct composable::Store

source ·
pub struct Store<State: Reducer> { /* private fields */ }
Expand description

The state container for the application.

§Threading

Implementations§

source§

impl<State: Reducer> Store<State>

source

pub fn with_initial(state: State) -> Self
where State: Send + 'static, <State as Reducer>::Action: Send, <State as Reducer>::Output: Send + From<State>,

Creates a new Store with state as its initial state.

If State is not Send, then new or default can be used instead.

source

pub fn new<F>(with: F) -> Self
where F: FnOnce() -> State + Send + 'static, <State as Reducer>::Action: Send + 'static, <State as Reducer>::Output: Send + From<State> + 'static,

Creates a new Store with its initial state generated by a function.

Useful if State is not Send, but the arguments used to construct it are.

source

pub fn send(&self, action: impl Into<<State as Reducer>::Action>)

Calls the Store’s Reducer with action.

Takes an Into<Action> so that both child and parent Actions may be sent easily.

source

pub fn into_inner(self) -> <State as Reducer>::Output

Stops the Store’s runtime and returns its current state value.

§Note

Care should be exercised when using this method in applications that utilize asynchronous Effects. into_inner makes a “best effort” to wait until any pending tasks are completed but it is not guaranteed.

Trait Implementations§

source§

impl<State> Default for Store<State>
where State: Default + Reducer, <State as Reducer>::Action: Send + 'static, <State as Reducer>::Output: Send + From<State> + 'static,

source§

fn default() -> Self

Creates a new Store with a default initial state.

Auto Trait Implementations§

§

impl<State> Freeze for Store<State>

§

impl<State> !RefUnwindSafe for Store<State>

§

impl<State> Send for Store<State>
where <State as Reducer>::Action: Send,

§

impl<State> Sync for Store<State>
where <State as Reducer>::Action: Send,

§

impl<State> Unpin for Store<State>

§

impl<State> !UnwindSafe for Store<State>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.