redux-createreducer

2.0.0 • Public • Published

create-reducer

Creates a Redux reducer from an ActionHandlers object

build status npm version npm downloads

CreateReducer :: State a, ActionHandlers b, Action c => a,b -> (a,c -> a)

ActionHandlers :: ActionType a, State b, Action c => {a: (b,c -> b), ...}

Creates a reducer from an object that each property name is an actionType and its value is a function that receive a state and an action and return a new state

How to install

$ npm install redux-createreducer --save

Example:

import createReducer from 'redux-createreducer';

const initialState = 0;
const actionHandlers = {
	'INCREMENT': (state, action) => state + 1,
	'DECREMENT': (state, action) => state - 1
};

const reducer = createReducer(initialState, actionHandlers);

Readme

Keywords

none

Package Sidebar

Install

npm i redux-createreducer

Weekly Downloads

7

Version

2.0.0

License

MIT

Last publish

Collaborators

  • tiagofreres