redux-routine

0.2.0 • Public • Published

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

createReducerFromInitialState(initialState)function

Creates simple reducer from initial state object

createCollectionActions(itemKey)object

Creates collection actions

createReducerRoutine(itemKey, initialItemState)Object

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

createSimpleReducer(defaultValue, [key]) ⇒ *

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

Param Type Default Description
defaultValue string | number | boolean | null Default state value. Can't be {undefined}
[key] string | null null determines what part of payload should be watched for changes

createReducerFromInitialState(initialState) ⇒ function

Creates simple reducer from initial state object

Param Type Description
initialState Object.<String, *> Key-Value pairs for creating simple reducers

createCollectionActions(itemKey) ⇒ object

Creates collection actions

Param Type
itemKey string

createReducerRoutine(itemKey, initialItemState) ⇒ Object

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

Param Type
itemKey string
initialItemState object

Readme

Keywords

Package Sidebar

Install

npm i redux-routine

Weekly Downloads

0

Version

0.2.0

License

MIT

Last publish

Collaborators

  • ezhikov