0.2.0 • Published 9 years ago
redux-routine v0.2.0
#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
| 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 |