Reducer
Defines a reducer against your model.
API
Reducer<
State = any,
Action extends ReduxAction = ReduxAction
>
State
The type for the state that will be managed by the reducer.
Action
The type of the actions that may be received by the reducer.
Example
import { Reducer, reducer } from 'easy-peasy';
interface StoreModel {
todos: Reducer<string[]>;
}
const storeModel: StoreModel = {
todos: reducer((state = [], action) => {
switch (action.type) {
case 'ADD_TODO': return [...state, action.payload];
default: return state;
}
})
}