diff options
Diffstat (limited to 'web/src/js/ducks/utils/store.js')
-rw-r--r-- | web/src/js/ducks/utils/store.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/web/src/js/ducks/utils/store.js b/web/src/js/ducks/utils/store.js index 3252d697..9ea4f02e 100644 --- a/web/src/js/ducks/utils/store.js +++ b/web/src/js/ducks/utils/store.js @@ -13,6 +13,22 @@ const defaultState = { viewIndex: {}, } +/** + * The store reducer can be used as a mixin to another reducer that always returns a + * new { byId, list, listIndex, view, viewIndex } object. The reducer using the store + * usually has to map its action to the matching store action and then call the mixin with that. + * + * Example Usage: + * + * import reduceStore, * as storeActions from "./utils/store" + * + * case EVENTLOG_ADD: + * return { + * ...state, + * ...reduceStore(state, storeActions.add(action.data)) + * } + * + */ export default function reduce(state = defaultState, action) { let { byId, list, listIndex, view, viewIndex } = state |