redux-switch-action
v2.0.0
Published
Slightly more concise reducer switching
Downloads
25
Maintainers
Readme
Redux Switch Action
Slightly more concise reducer switching for Flux Standard Actions.
const switchAction = createSwitchAction({
[ADD]: addReducer,
[SUB]: subReducer,
});
export function reducer(state = 0, action) {
return switchAction(state, action);
}
function addReducer(state, {payload}) {
return state + payload.amount;
}
function subReducer(state, {payload}) {
return state - payload.amount;
}