redux-switch-action

2.0.0 • Public • Published

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;
}

Package Sidebar

Install

npm i redux-switch-action

Weekly Downloads

0

Version

2.0.0

License

MIT

Last publish

Collaborators

  • qwtel