Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 4x 1x 3x 6x 6x | /** * * @param {Object} reducers an object containing reducers * @description applies an action to a group of reducers * it also collects any initial state related to the reducer invoked * @returns {Object} a combination of reducers */ export const combineReducers = reducers => { return (state = {}, action) => { return Object.keys(reducers).reduce((prev, curr) => { const invoke = reducers[curr](state[curr], action); return { ...prev, [curr]: invoke }; }, {}); }; }; export default combineReducers; |