First of all thank's so much @Datorama and @NetanelBasal for the akita project! It's awesome and I love it!
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ x] Support request
[ ] Other... Please describe:
I have 3 Entities similar to the movies, genre and actor demo. I wanted to add StateHistoryPlugin to add undo and redo features. I do it with:
this.stateHistory = new StateHistoryPlugin(this.moviesQuery);
Then I do 3 actions:
When I press undo ( this.stateHistory.undo();) I get the action 1 undone.
The expected behaviour is "the expected" but what if we get the action 3 undone?
We have 3 different stores and what's happening is expected but:
Thanks again for the awesome work!
Hey,
Based on your example use-case, you can do the following:
[stateHistoryMovies, stateHistoryGenres, stateHistoryActors].forEach(plugin => plugin.undo())
It will undo the latest state in all the stores. It's a workaround but I think it could be a great addition to Akita.
thank's for the suggestion :)
It will undo the latest state in all the stores
I might don't understand your use-case. Can you please create a demo in stackblitz so we can experiment with the use-case?
Sorry didn't had much time to get an example working. Will try to get the demo done this weekend.
So here is my example:
https://stackblitz.com/edit/akita-movies-undo-redo-3querys-history
In this example I added a button that perform 3 actions one on each entity - movie, genre and actor. When the user presses undo he is expecting to undo all the 3 actions. But only the movie action is undone because its the only being passed to the state history plugin.
The option that you provided above would solve this problem:
[stateHistoryMovies, stateHistoryGenres, stateHistoryActors].forEach(plugin => plugin.undo())
But it would not differentiate when the user performed each action alone so when the user presses undo it will perform one undo in each store even if the user wanted to undo action by action.
I think we need some CombinedStateHistoryPlugin. What do you think?
Thanks.
@shaharkazaz will work on that.
A quick update. We decided that we're not going to do that because there was no demand. We'll reconsider if there will be a demand — closing for now.
Most helpful comment
@shaharkazaz will work on that.