Closed mwalsher closed 8 years ago
It looks like historyWithoutRevert
is empty when the revert is being applied, which I believe is why the reducer isn't being called.
So your callback adds an error message and ACTION_ERROR should put that in the state
On Mon, Feb 22, 2016, 10:29 PM Mike Walsh notifications@github.com wrote:
It looks like historyWithoutRevert is empty when the revert is being applied, which I believe is why the reducer isn't being called.
— Reply to this email directly or view it on GitHub https://github.com/mattkrick/redux-optimistic-ui/issues/5#issuecomment-187506811 .
That's exactly what is supposed to happen (and in fact does happen if I set optimistic: false
to disable your reducer enhancer), however my ACTION_ERROR action isn't getting triggered when a REVERT occurs.
Changing your code as follows fixes the issue:
case COMMIT:
let committedState = applyCommit(state, id, reducer)
return committedState.set('current', reducer(committedState.get('current'), action))
case REVERT:
let revertedState = applyRevert(state, id, reducer)
return revertedState.set('current', reducer(revertedState.get('current'), action))
could you write a failing test case? I still think this is a middleware error instead of something wrong with the package
reading through this again, are you saying that you commit something and THEN revert it? If so then that's expected behavior. SUCCESS & ERROR are mutually exclusive
believe this is was an implementation problem, since the optimistic-ui result should be part of the action meta data & not an action itself
It seems the reducer isn't being called after an optimistic action is committed/reverted. Is this intentional? Or am I missing something? If I remove the
optimistic
value frommeta
, the reducer is called as expected.Basically I am trying to set an error message in the event that an optimistic action fails. Looking at your meatier example, it seems that this should be possible?
Here is the relevant API code which dispatches the optimistic actions: