Open nmay231 opened 4 years ago
iirc, my use case was that I was dispatching a 'save' action, which didn't modify the business part of the store, just the save state. When the end user would try to undo beyond this 'extra' action, it would look like nothing changed, when really they were undoing the "save" action. I was able to work around this with some funky grouping logic, but I would have preferred a feature like this 👍
Any update on this feature ?
I'm submitting a ...
What is the current behavior/state of the project?
There is currently no way to change existing history in
.past
and.future
without completely clearing the history.What is the desired behavior?
It might be useful to remove certain parts of history in the past or future array by dispatching an action. For example, an action could be dispatched to remove states at index 3 to 7 in the past array.
If this is a feature request, what is the use case for changing the behavior?
An end-user could be presented with a history of states and choose to "group" ranges of changes into one change. In the background, this would really be removing ranges of history.
And it could make history "housecleaning" easier. While it would be more desirable to achieve clean histories with filter and groupBy, it might be easier sometimes to just remove unwanted history after the fact.
Implementation and other information
The implementation that I can see as the most general would be action(s) defining an array splice operation. We could add two action creators:
splicePast
andspliceFuture
. Both have the function signature similar to splice and return the following action:Note:
deleteCount
does have a different default than Array.splice. I think it makes more sense for this case, but I'm not attached to using 1.Even if this exact implementation is not used, something to be able to change existing history could be useful.
This is inspired by user @dannyharding10 in gitter.