createReducer<State> function
A utility function that combines several On reducer objects.
Example
Reducer<int> counterReducer = createReducer([
On<int, IncrementCounterAction>(
(counter, action) => counter + 1,
),
On<int, DecrementCounterAction>(
(counter, action) => counter - 1,
),
]);
Implementation
Reducer<State> createReducer<State>(
Iterable<On<State, StoreAction>> ons,
) {
return (State state, StoreAction action) {
for (final onAction in ons) {
state = onAction(state, action);
}
return state;
};
}