pub struct Store<State, Service, Action> {
pub state: StateWrapper<State>,
pub service: Service,
/* private fields */
}Expand description
Main struct for the state machine.
Exposes a Store::dispatch method, using
which actions can be dispatched, which triggers a
Fields§
§state: StateWrapper<State>Current State.
Immutable access can be gained using store.state.get().
Mutation can only happen inside reducer.
service: ServiceImplementations§
Source§impl<State, Service, Action> Store<State, Service, Action>where
Service: TimeService,
Action: EnablingCondition<State>,
impl<State, Service, Action> Store<State, Service, Action>where
Service: TimeService,
Action: EnablingCondition<State>,
Sourcepub fn new(
reducer: Reducer<State, Action>,
effects: Effects<State, Service, Action>,
service: Service,
initial_time: SystemTime,
initial_state: State,
) -> Self
pub fn new( reducer: Reducer<State, Action>, effects: Effects<State, Service, Action>, service: Service, initial_time: SystemTime, initial_state: State, ) -> Self
Creates a new store.
pub fn service(&mut self) -> &mut Service
Sourcepub fn monotonic_to_time(&self, monotonic_time: Instant) -> u64
pub fn monotonic_to_time(&self, monotonic_time: Instant) -> u64
Convert monotonic time to system clock in nanoseconds from epoch.
Sourcepub fn dispatch<T>(&mut self, action: T) -> boolwhere
T: Into<Action> + EnablingCondition<State>,
pub fn dispatch<T>(&mut self, action: T) -> boolwhere
T: Into<Action> + EnablingCondition<State>,
Dispatch an Action.
Returns true if the action was enabled, hence if it was dispatched
to reducer and then effects.
If action is not enabled, we return false and do nothing.
pub fn dispatch_callback<T>(&mut self, callback: Callback<T>, args: T) -> bool
Sourcepub fn sub_dispatch<A, S>(&mut self, action: A) -> bool
pub fn sub_dispatch<A, S>(&mut self, action: A) -> bool
Dispatch an Action (For SubStore).
Returns true if the action was enabled, hence if it was dispatched
to reducer and then effects.
If action is not enabled, we return false and do nothing.
Trait Implementations§
Auto Trait Implementations§
impl<State, Service, Action> Freeze for Store<State, Service, Action>
impl<State, Service, Action> RefUnwindSafe for Store<State, Service, Action>where
Service: RefUnwindSafe,
State: RefUnwindSafe,
impl<State, Service, Action> Send for Store<State, Service, Action>
impl<State, Service, Action> Sync for Store<State, Service, Action>
impl<State, Service, Action> Unpin for Store<State, Service, Action>
impl<State, Service, Action> UnwindSafe for Store<State, Service, Action>where
Service: UnwindSafe,
State: UnwindSafe,
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