Closed zernie closed 7 years ago
Hi Zernie,
To make sure I understand what you mean, what is the effect of doing this? Do you want it to apply the two handlers in order, i.e.
const reducer = reducerWithInitialState(INITIAL_STATE)
.caseWithHandlers(actionCreator, [handlerA, handlerB])
is equivalent to
function reducer(state = INITIAL_STATE, action) {
if (isType(action, actionCreator) {
return handlerB(handlerA(state, action.payload), action.payload);
}
}
Can you describe a situation where this would be useful, i.e. why would defining a handler in two parts increase clarity?
Supposing there's a good use case for this, you can already achieve this functionality by using reduce-reducers, i.e.
.case(action, reduceReducers(handlerA, handlerB))
Because this is already possible through composition, I'm inclined to say it is unnecessary to include this functionality into the API of this library. Let me know if you disagree.
Closing for inactivity. Feel free to re-open if you have more comments.
Currently there is no way to specify a reducer for a single action type but with multiple handlers. It would look like this: