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

feat(persist-state): 🔥 Add callback to change state before save #495

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

johnfewell
Copy link
Contributor

@johnfewell johnfewell commented Oct 25, 2023

The preStorageUpdate feature in the persistState function allows you to modify the state of your application before it is saved to storage. This is particularly useful when you want to remove or transform certain parts of the state before persisting it. For example, you might want to remove sensitive data or unnecessary information. The function receives the store's name and the current state as parameters and should return the modified state which will then be saved to storage.

Closes: 490

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?

There is no option to update the state before saving to storage.

Issue Number: 490

What is the new behavior?

There is an optional callback to update the state before saving to storage called preStorageUpdate.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

The preStorageUpdate feature allows the modification of state before it
is saved to storage.

✅ Closes: 490
@stackblitz
Copy link

stackblitz bot commented Oct 25, 2023

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

@NetanelBasal NetanelBasal merged commit e21793a into ngneat:master Oct 26, 2023
1 check passed
@johnfewell johnfewell deleted the feature/add-preStorageUpdate branch October 26, 2023 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

preStorageInit alternative to Akita state management
2 participants