Trait reactive_state::middleware::Middleware [−][src]
pub trait Middleware<State, Action, Event, Effect> { fn on_reduce(
&self,
store: &Store<State, Action, Event, Effect>,
action: Option<&Action>,
reduce: ReduceFn<State, Action, Event, Effect>
) -> ReduceMiddlewareResult<Event, Effect> { ... } fn process_effect(
&self,
_store: &Store<State, Action, Event, Effect>,
effect: Effect
) -> Option<Effect> { ... } fn on_notify(
&self,
store: &Store<State, Action, Event, Effect>,
events: Vec<Event>,
notify: NotifyFn<State, Action, Event, Effect>
) -> Vec<Event> { ... } }
Expand description
Middleware
used to modify the behaviour of a Store during a
Store::dispatch().
Provided methods
fn on_reduce(
&self,
store: &Store<State, Action, Event, Effect>,
action: Option<&Action>,
reduce: ReduceFn<State, Action, Event, Effect>
) -> ReduceMiddlewareResult<Event, Effect>
[src]
fn on_reduce(
&self,
store: &Store<State, Action, Event, Effect>,
action: Option<&Action>,
reduce: ReduceFn<State, Action, Event, Effect>
) -> ReduceMiddlewareResult<Event, Effect>
[src]This method is invoked by the Store during a
Store::dispatch() just before the Action
is sent to the
Reducer. It is necessary to call the
provided reduce
function, which executes subsequent
middleware and runs the Reducer, and usually
the events produced by the reduce
function are returned from
this method.
This method allows modifying the action in question, or even removing it, preventing the Reducer from processing the action. It also allows modifying the events produced by the Reducer before the Middleware::on_notify() is invoked and they are sent to the Store listeners.
fn process_effect(
&self,
_store: &Store<State, Action, Event, Effect>,
effect: Effect
) -> Option<Effect>
[src]
fn process_effect(
&self,
_store: &Store<State, Action, Event, Effect>,
effect: Effect
) -> Option<Effect>
[src]Process an Effect
. Returns None
if the effect was
processed/consumed by this handler, otherwise returns
Some(effect)
.
fn on_notify(
&self,
store: &Store<State, Action, Event, Effect>,
events: Vec<Event>,
notify: NotifyFn<State, Action, Event, Effect>
) -> Vec<Event>
[src]
fn on_notify(
&self,
store: &Store<State, Action, Event, Effect>,
events: Vec<Event>,
notify: NotifyFn<State, Action, Event, Effect>
) -> Vec<Event>
[src]This method is invoked by the Store during a
Store::dispatch() after the Reducer has
processed the Action
and all Middleware::on_reduce()
methods have completed, just before resulting events are
sent to the store listeners. It is necessary to call the
provided notify
function, which executes subsequent
middleware and then notifies the listeners.
This method allows modifying the events in question before the listeners are notified.
Implementors
impl<State, Action, Event, Effect> Middleware<State, Action, Event, Effect> for SimpleLoggerMiddleware where
Event: Clone + Hash + Eq + Debug,
State: Debug,
Action: Debug,
Effect: Debug,
[src]
impl<State, Action, Event, Effect> Middleware<State, Action, Event, Effect> for SimpleLoggerMiddleware where
Event: Clone + Hash + Eq + Debug,
State: Debug,
Action: Debug,
Effect: Debug,
[src]simple_logger
only.fn on_reduce(
&self,
store: &Store<State, Action, Event, Effect>,
action: Option<&Action>,
reduce: ReduceFn<State, Action, Event, Effect>
) -> ReduceMiddlewareResult<Event, Effect>
[src]
&self,
store: &Store<State, Action, Event, Effect>,
action: Option<&Action>,
reduce: ReduceFn<State, Action, Event, Effect>
) -> ReduceMiddlewareResult<Event, Effect>
fn process_effect(
&self,
_store: &Store<State, Action, Event, Effect>,
effect: Effect
) -> Option<Effect>
[src]
&self,
_store: &Store<State, Action, Event, Effect>,
effect: Effect
) -> Option<Effect>
fn on_notify(
&self,
store: &Store<State, Action, Event, Effect>,
events: Vec<Event>,
notify: NotifyFn<State, Action, Event, Effect>
) -> Vec<Event>
[src]
&self,
store: &Store<State, Action, Event, Effect>,
events: Vec<Event>,
notify: NotifyFn<State, Action, Event, Effect>
) -> Vec<Event>
impl<State, Action, Event, Effect> Middleware<State, Action, Event, Effect> for WebLoggerMiddleware where
State: Serialize,
Action: Serialize + Display,
Event: Clone + Hash + Eq + Serialize,
Effect: Serialize,
[src]
impl<State, Action, Event, Effect> Middleware<State, Action, Event, Effect> for WebLoggerMiddleware where
State: Serialize,
Action: Serialize + Display,
Event: Clone + Hash + Eq + Serialize,
Effect: Serialize,
[src]web_logger
only.fn on_reduce(
&self,
store: &Store<State, Action, Event, Effect>,
action: Option<&Action>,
reduce: ReduceFn<State, Action, Event, Effect>
) -> ReduceMiddlewareResult<Event, Effect>
[src]
&self,
store: &Store<State, Action, Event, Effect>,
action: Option<&Action>,
reduce: ReduceFn<State, Action, Event, Effect>
) -> ReduceMiddlewareResult<Event, Effect>
fn process_effect(
&self,
_store: &Store<State, Action, Event, Effect>,
effect: Effect
) -> Option<Effect>
[src]
&self,
_store: &Store<State, Action, Event, Effect>,
effect: Effect
) -> Option<Effect>
fn on_notify(
&self,
store: &Store<State, Action, Event, Effect>,
events: Vec<Event>,
notify: NotifyFn<State, Action, Event, Effect>
) -> Vec<Event>
[src]
&self,
store: &Store<State, Action, Event, Effect>,
events: Vec<Event>,
notify: NotifyFn<State, Action, Event, Effect>
) -> Vec<Event>