-
Notifications
You must be signed in to change notification settings - Fork 120
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: state initialization for feature stores #200
base: master
Are you sure you want to change the base?
Conversation
Feature stores do not receive the @ngrx/store/init action, thus the initialization of the state skipped the merge
Thanks for the PR @jderrough! Looks like this is the same change as #155. I'm a bit hesitant to merge this change in case it has unintended consequences. Can you think of any bugs this might introduce or do you think it's safe? I think the workaround to this issue is to add the |
Also, if I do merge this in, I would like to see a unit test added for this scenario if possible. |
@BBlackwo, this workaround doesn't fix the problem. Let me post here some examples.
Outcome: 👌, the object is saved and restored as expected
Outcome: 🙅♂️, the object is being loaded inside another object with the same name and, therefore, the rehydration is failing. No data is being saved (see n.3), therefore update is not happening.
Outcome: 🙅♂️, no data is being saved, so without the proper object in the storage the rehydration and the updating is impossible
Outcome: 🙅♂️, same as n.3: no data is being saved, so without the proper object in the storage the rehydration and the updating is impossible
Outcome: 🤦♂️, it works, yeah... but every feature can overwrite the values of other features. Definitely not a recommended approach.
Outcome: 🙄, it works... in a very, very dirty way. In order to avoid the overwriting issue, we're applying here a prefix to the key. At least this is something we can work with. Conclusions: |
When is this expected to merge ? I am facing this issue on feature module |
You could review this PR: fix: storage syncing for feature stores |
Feature stores do not receive the @ngrx/store/init action, thus the initialization of the state skipped the merge
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
State is initialized and merged when receiving the @ngrx/store/init action, but in the case of feature stores the first action received is @ngrx/store/update-reducers.
What is the new behavior?
State is now initialized and merged when receiving the @ngrx/store/init action or the @ngrx/store/update-reducers action.
Does this PR introduce a breaking change?
Other information