Closed SunlightBro closed 3 years ago
The store has a single, immutable state. So if you save a copy of the state and then reinstate it (replace the current state with the old one) you have your undo. So I'd say AsyncRedux (and Redux in general) already has this feature.
The problem is that this will replace all of the saved state, not only the deleted item. This could delete some other important state changes that happened between the delete and the undo.
So, for this to work you have to replace only the part of the state that contains the deleted item, and you must make sure the rest of the state remains consistent with the undeletion of the item.
So, I don't see a way to do this automatically or how AsyncRedux could help with that.
I had this thought of maybe having an undo feature in async_redux:
Image a class like this in this package,
you could use in your app like this (for example in a delete action):
That would after the Action is finished, display a Dialog similar to the UserExceptionDialog with an Undo-Button, that when pressed reverts to the previous state.
I know this could be solved outside of async_redux, but I think this is not something only I come across and it would be awesome to have something like as an easy to use implementation for this Undo feature. Let me know what you think.