Closed aaronbeall closed 7 years ago
Only the start of the transaction should have the type: BEGIN
bit, so it should look like:
dispatch({type: DRAG, optimist: { type: BEGIN, id: 0 }});
dispatch({type: DRAG, optimist: { id: 0 }});
dispatch({type: DRAG, optimist: { id: 0 }});
dispatch({type: DROP, optimist: { id: 0 }});
// ... after server round-trop
dispatch({type: DROP_SUCCESS, optimist: { type: COMMIT, id: 0 }});
// or
dispatch({type: DROP_REJECTED, optimist: { type: REVERT, id: 0 }});
@ForbesLindesay Thanks for the follow up! I knew multiple BEGIN
was not right but I did not know you can update by passing no type
at all. Is this example in the documentation? Maybe a type UPDATE
or something would be more intuitive. Cheers.
I would be very happy to accept a pull request to update the README and make this clearer :)
I have a series of actions that happen as a set of changes that eventually all get committed or reverted. Something like this:
As is, the
REVERT
doesn't work. All theoptimist
state keys get removed, but my state doesn't revert to its state before the firstDRAG
action. I need to revert all the actions, not just the last or the first. Is this possible without storing and reverting unique ids for every step?