reduxreducercreator

0.0.7 • Public • Published

reduxreducercreator [NPM version]

https://github.com/nirmaoz/reduxreducercreator

ReduxReducerCreator lets you create a reducer without using the switch statement. Provides a default handler for non-existing action types that returns the state. The default handler is replaceable (just provide it as the last argument).

Installation

$ npm i --save reduxreducercreator

Usage

const reducerCreator = require("./reduxreducercreator");

let newReducer = (state, action) => {
  return reducerCreator(state, action, {
    action_type_1: (state, action) => { //action handler for type_1
      return ...
    },
    action_type_2: (state, action) => { //action handler for type_2
      return ...
    }
  });
};

API

reduxreducercreator ( state, action, actionHandlers, defaultHandler=()=>return state )

Tests

Tested using Mocha and Expect

License

MIT © Nir Maoz

Package Sidebar

Install

npm i reduxreducercreator

Weekly Downloads

4

Version

0.0.7

License

MIT

Unpacked Size

3.51 kB

Total Files

4

Last publish

Collaborators

  • maoznir