Skip to content

Commit dd10269

Browse files
committed
patch/improvement: createSimpleReduxModule was effectively double-qualifiying the "update" dispatcher; now it's simpler
1 parent 7ab0503 commit dd10269

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/createReduxModule.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@ const mapKeys = (o, f) => {
99
};
1010

1111
const createSimpleReduxModule = (storeKey, initialState) => {
12-
const UPDATE_ACTION = `${storeKey}-update`;
1312
const [hook, dispatchers, virtualStore] = createReduxModule(storeKey, initialState, {
14-
[UPDATE_ACTION]: (state, payload) => payload
13+
update: (state, payload) => payload
1514
});
16-
return [hook, dispatchers[UPDATE_ACTION], virtualStore];
15+
return [hook, dispatchers.update, virtualStore];
1716
};
1817

1918
const createReduxModule = (storeKey, initialState, reducers, store = getStore()) => {
2019
if (!reducers) return createSimpleReduxModule(storeKey, initialState);
2120

2221
let getQualifiedActionType = (type) => `${storeKey}-${type}`;
2322
let qualifiedReducers = {}
24-
Object.keys(reducers).map( key => {return qualifiedReducers[getQualifiedActionType(key)] = reducers[key]});
23+
Object.keys(reducers).map(key => { return qualifiedReducers[getQualifiedActionType(key)] = reducers[key] });
2524

2625
store.injectReducer(storeKey, (state = initialState, { type, payload }) =>
2726
qualifiedReducers[type] ? qualifiedReducers[type](state, payload) : state

0 commit comments

Comments
 (0)