Effect

Enum Effect 

Source
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> 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>,

Source§

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>,

Source§

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.