-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
What is the current behavior?
'forFeature' part of the Store is being used in the 'forFeature' @effects (by combining Action with withLatestFrom(this.store.select(getFeatureState))) however the store at that time hasn't been updated with feature part. It gets updated a bit later when @ngrx/store/update-reducers is triggered.
This happens when there are > 1 EffectsModule.forFeature modules.
Expected behavior:
I've tried to defer(() => {...}) the whole thing, but apparently Effects are subscribed to earlier than Store is patched with feature.
Minimal reproduction of the problem with instructions:
Here is my repro: https://stackblitz.com/edit/store-forfeature-issue?embed=1&file=app/app.module.ts
Important parts:
OtherFeatureModuleis imported beforeFeatureModulein theAppModule.OtherFeatureModulehasEffectsModule.forFeature([...])FeatureModulehasEffectsModule.forFeature([...])andStoreModule.forFeature({...})@Effect()that is part ofFeatureModuleusesthis.store.select(selectorThatUsesFeaturePartOfTheStore)
workarounds:
this.store.select(selectorThatUsesFeaturePartOfTheStore)and only usethis.store.select(selectorThatUsesRootPartOfTheStore)- try to push
this.store.select(selectorThatUsesFeaturePartOfTheStore)into the payload of the Action
None of the workarounds look particular appealing to me.
Thank you @brandonroberts for debugging it with me.
Reactions are currently unavailable
