0.0.7 • Published 5 years ago

reduxreducercreator v0.0.7

Weekly downloads
14
License
MIT
Repository
github
Last release
5 years ago

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