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 |
function
createReducerFromInitialState(initialState) ⇒ Creates simple reducer from initial state object
Param | Type | Description |
---|---|---|
initialState | Object.<String, *> |
Key-Value pairs for creating simple reducers |
object
createCollectionActions(itemKey) ⇒ Creates collection actions
Param | Type |
---|---|
itemKey | string |
Object
createReducerRoutine(itemKey, initialItemState) ⇒ Creates all routine for collection: actionCreators, action types, item reducer and collection {Map} reducer
Param | Type |
---|---|
itemKey | string |
initialItemState | object |