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

fix(store): initial state should not be overwritten by defaults #904

Merged
merged 2 commits into from
Mar 7, 2019

Conversation

markwhitfeld
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[X] Bugfix
[ ] 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?

Issue Number: #902
There was a regression caused by PR #791 in this line:
https://github.com/ngxs/store/pull/791/files#diff-084c7b85b6562e3126b58451d5f8943aR20

This only affects Emitter plugin users. This is because of the way that Emitter inherits from Store to create an EmitStore. I found the point at which the state was being overwritten. See this stackblitz:
https://stackblitz.com/edit/ngxs-no-initial-state-debug

Ngxs does not expect a plugin to inherit from Store and essentially run this code twice. Emitter does some things with Ngxs internals that are not usual plugin behaviours.

What is the new behavior?

This code is now protected from being run twice. The default values are only written into the store if there is no current value in the store.

Does this PR introduce a breaking change?

[ ] Yes
[X] No

@markwhitfeld
Copy link
Member Author

I have tested HMR in the integration app and can confirm that it is working great.

@markwhitfeld markwhitfeld requested a review from splincode March 7, 2019 11:34
@splincode splincode merged commit a3fec91 into master Mar 7, 2019
@markwhitfeld markwhitfeld deleted the fix/issue-902-fix-emitter-initial-state-defaults branch March 7, 2019 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants