These are chat archives for jdubray/sam
I am cross-posting some of the discussion I had in the ngrx/core room
When you compare Redux with SAM, the arguments boils down that in Redux, when you write this kind of code:
case INCREMENT: return state + 1;
the reducer is coupling the action itself:
counter += 1 which adds one to a given value
state.counter = counter which assigns a value to the counter property.
All I am suggesting with SAM is to take the action logic outside the reducer, the reducer keeping its core role to mutate state. The same "reducer" logic could work just as well with different actions (incrementByN).
I am not quite sure anyone would see this kind of factoring in the context of mutating state as a bad idea