3 ms·
> And you need to have reliable 'rollbacks' on the client when server rejects the action for some reason....'ve solved all these problems eventually, but it too
by eric_bullington 11y ago
> And you need to have reliable 'rollbacks' on the client when server rejects the action for some reason....'ve solved all these problems eventually, but it took much more time for me than building the happy path.
I'm sure you figured this out, but having an immutable data structure at the root of your React application is great for rollbacks. And then maintain an array with a reference to the various data structures, however deep you need (within reason), and pop or push them as needed to rollback/roll forward.
- hakanderyal 11y agoYes, I'm using Redux, and never modify the state. But I also needed to rollback only the rejected action, and keep the rest of the actions that user did after the rejected action intact. That presented a whole lot of different edge cases. I created a solution based on redux-optimist[1], modified to my apps specific needs. [1]: https://github.com/ForbesLindesay/redux-optimist https://github.com/ForbesLindesay/redux-optimist