Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to clear undo / redo stack? #7

Closed
Sueloo opened this issue Feb 26, 2019 · 7 comments
Closed

Is it possible to clear undo / redo stack? #7

Sueloo opened this issue Feb 26, 2019 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@Sueloo
Copy link

Sueloo commented Feb 26, 2019

Hi,

Thanks for a great plugin! Is it possible to clear the undo / redo stack?

@mlnmln
Copy link
Member

mlnmln commented May 6, 2019

hi @Sueloo ,

sorry for not getting back earlier, we recently moved the repository and missed a couple of notifications.

@andrewbeng89 andrewbeng89 added the enhancement New feature or request label May 7, 2019
@andrewbeng89
Copy link
Member

@Sueloo thanks for your question 👍and apologies for the late reply. At the moment, this feature is not available, but should be relatively straightforward to implement.

To get started, could you please confirm whether the criteria for this feature:

  • The clear function will be triggered by a noop action called [optional-namespace/]clear
  • If there are mutations remaining in the done stack, clear will undo these mutations (without adding them to the undone stack), and all necessary undoCallbacks will be called
  • If there are mutations remaining in the undone stack, clear will set undone to an empty stack

@ma7moudat
Copy link

Hey @andrewbeng89 !
I have a similar use case and an implementation of your specification would be just what I need. Is there a plan to include this in upcoming releases?

@andrewbeng89
Copy link
Member

Hi @ma7moudat thanks for the feedback on this enhancement to the plugin. I will be creating some test specs for the feature shortly.

One thing I'd like to clarify about the new feature is the difference between clear and reset (also yet to be implemented):

  • clear implies that the state of the store will be reinitialised to its original state, i.e. the state when no mutations had been applied
  • reset implies that the state of the store will remain the same at this point, but undo/redo stacks are emptied, i.e. the subsequent undo after the next mutation will return the state of the store to the state when reset was called

@ma7moudat
Copy link

wow! thanks a lot for the quick response and implementation @andrewbeng89 ❤️
and you're right, clear and reset are both needed... in my case reset would be more relevant, since I'm working on forms with undo/redo functionality and the user should be able to reset the form to repopulate the original values without emptying the state (which clear does from your description)

@andrewbeng89
Copy link
Member

Thanks @ma7moudat! The next steps would be to work on some tests for reset, followed by implementation ;)

@andrewbeng89
Copy link
Member

@ma7moudat the clear feature is now available in v1.2.0. Could you please try this out? I have also created #13 to prepare the reset feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants