FutureReducer<State, Action, Payload> class
A utitlity Reducer
class aimed at simplifying the boilerplate
written in respective reducers for various FutureActions.
Usage: {@tool snippet}
class CounterState{
int value = 0;
}
class IncrementAction {}
var reducer = FutureReducer<CounterState, IncrementAction, int>
(successReducer: successReducer);
CounterState successReducer(CounterState prevState,
FutureSucceededAction<IncrementAction>) {
return prevState..value = prevState.value + 1;
}
{@end-tool}
Constructors
-
FutureReducer({required State successReducer(State, FutureSucceededAction<
Action, Payload> ), State pendingReducer(State, FuturePendingAction<Action> )?, State failedReducer(State, FutureFailedAction<Action> )?}) -
Creates a
Reducer
which handles thesuccess
,pending
andfailed
state of the Future passed to theFutureMiddleware
.factory
Properties
-
failedReducer
→ State Function(State, FutureFailedAction<
Action> ) -
A reducer to handle FutureFailedAction, when you need to use custom
implementation to handle the action. If not null, this will be used
instead of
FutueReducerDefaults.failedReducer
.final - hashCode → int
-
The hash code for this object.
no setterinherited
-
pendingReducer
→ State Function(State, FuturePendingAction<
Action> ) -
A reducer to handle FuturePendingAction, when you need to use custom
implementation to handle the action. If not null, this will be used
instead of FutureReducerDefaults.pendingReducer.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
successReducer
→ State Function(State, FutureSucceededAction<
Action, Payload> ) -
A reducer to handle FutureSucceededAction.
final
Methods
-
call(
State prevState, dynamic action) → State -
The
Reducer
function that converts the current state and action into a new state -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited