ngneat / elf

🧙‍♀️ A Reactive Store with Magical Powers
https://ngneat.github.io/elf/
MIT License
1.62k stars 93 forks source link

feat(state-history): 🔥 Add an option to control future state #475

Closed johnfewell closed 1 year ago

johnfewell commented 1 year ago

An option called resetFutureOnNewState has been added to the StateHistoryOptions interface. This option allows the user to control whether the future redo states should be cleared when a new state is added after the user has undone one or more state changes. The default value of this option is set to false, meaning that by default, the future states will not be cleared.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Currently, when a new state is added after the user has undone one or more state changes, the future redo states are not cleared.

Issue Number: N/A

What is the new behavior?

A new option called resetFutureOnNewState has been added to the StateHistoryOptions interface. This option allows the user to control whether the future redo states should be cleared when a new state is added after the user has undone one or more state changes. The default value of this option is set to false, meaning that by default, the future states will not be cleared.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

This new feature provides more control to the user over the state history and can prevent unnecessary state changes from being redone. It is a useful feature for applications that need finer control over state changes and their history.

stackblitz[bot] commented 1 year ago

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.