pub enum Effect<Action> {
Action(Action),
Task(Box<dyn FnOnce() + Send>),
Thunk(Box<dyn FnOnce(Box<dyn Dispatcher<Action>>) + Send>),
Function(String, EffectFunction),
}Expand description
Represents a side effect that can be executed.
Effect is used to encapsulate actions that should be performed as a result of a state change.
an effect can be either simple function or more complex thunk that require a dispatcher.
Variants§
Action(Action)
An action that should be dispatched.
Task(Box<dyn FnOnce() + Send>)
A task which will be executed asynchronously.
Thunk(Box<dyn FnOnce(Box<dyn Dispatcher<Action>>) + Send>)
A task that takes the dispatcher as an argument.
Function(String, EffectFunction)
A function which has a result. The result is an Any type which can be downcasted to the expected type, It is useful when you want to produce an effect without any dependency of ‘store’
§Caution
The result default ignored, if you want to get the result of the function,
you can use a middleware like TestEffectMiddleware
Auto Trait Implementations§
impl<Action> Freeze for Effect<Action>where
Action: Freeze,
impl<Action> !RefUnwindSafe for Effect<Action>
impl<Action> Send for Effect<Action>where
Action: Send,
impl<Action> !Sync for Effect<Action>
impl<Action> Unpin for Effect<Action>where
Action: Unpin,
impl<Action> !UnwindSafe for Effect<Action>
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