modular-redux-thunk
modular-redux-thunk copied to clipboard
Suggestion: `selector` as string sugar
I've noticed a very common pattern when writing single-value modules:
const someValue = {
reducer: (state = null, action) => {
switch (action.type) {
case SOME_ACTION:
return action.payload
default:
return state;
}
},
// Note the identity selector here
selectors: { getOrgsTotalCount: (state) => state },
actions: { someAction: /*...*/},
};
It might be slightly convenient to instead write this property as:
const someValue = {
reducer: /* same as before */,
// Note the identity selector here
selector: 'getOrgsTotalCount',
actions: /* same as before */,
};