0.2.0 • Published 8 years ago

redux-routine v0.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

#Redux routine

Set of small utils for creation of basic redux routine as collection reducer (uses Map for collection state), item reducer, actionCreators and basic action types (ADD, REMOVE, CHANGE)

Usage example

import {createReducerRoutine} from 'redux-routine';
const initialState = {
   text: '',
   completed: false,
};
const {todos, todo, ACTION_TYPE, actionCreators} = createReducerRoutine('todo', initialState);
const store = createStore(todos);

##Docs

createSimpleReducer(defaultValue, key) ⇒ *

Creates simple reducer which not reacts on particular action, but watching specific key in payload, if provided

ParamTypeDefaultDescription
defaultValuestring | number | boolean | nullDefault state value. Can't be {undefined}
keystring | nullnulldetermines what part of payload should be watched for changes

createReducerFromInitialState(initialState) ⇒ function

Creates simple reducer from initial state object

ParamTypeDescription
initialStateObject.<String, *>Key-Value pairs for creating simple reducers

createCollectionActions(itemKey) ⇒ object

Creates collection actions

ParamType
itemKeystring

createReducerRoutine(itemKey, initialItemState) ⇒ Object

Creates all routine for collection: actionCreators, action types, item reducer and collection {Map} reducer

ParamType
itemKeystring
initialItemStateobject