blob: 68602777c25ff00ac45b1756df905a233c528008 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
/**
* Helper to create a reducer that extend the store.
*
* @param {String} property
* @param {Function(state, action): state} reduce
* @return {Function(state, action): state}
*/
function createReducer(name, reduce) {
return (state, action) => {
const value = state[name];
state[name] = reduce(value, action);
return state;
};
}
module.exports = createReducer;
|