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

Order of importing StoreModule.forFeature and EffectsModule.forFeature matters with selectors in effects when lazy loading #219

Closed
RobHelgeson opened this issue Jul 31, 2017 · 1 comment

Comments

@RobHelgeson
Copy link

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
[ ] Support request

What is the current behavior?

If you use module lazy loading and import EffectsModule before the StoreModule, and use a selector in an effect, it will fail, with he selector unable to find the properties it needs on the store. Apparently the slice has not been added by the time the effect is fired. (I guess the effects start firing as soon as forFeature is called.)

This only when EffectsModule.forFeature() appears before StoreModule.forFeature() in the lazy loaded child module configuration.

Expected behavior:

Order of EffectsModule.forFeature() and StoreModule.forFeature() should not matter in imports.

Minimal reproduction of the problem with instructions:

It took me a while to figure it out (and a second to fix it) in my code, and then took quite a bit of fiddling in plunker to get it recreated again, but I have carved it down to just the essentials now.

Changing the order of the module imports in the following plunker causes or relieves the error (Swap lines 51 & 52 of src/zr-book-order.module.ts to see the error disappear): http://plnkr.co/edit/RfrqwsowTXDuS4SLl6oD?p=preview

Version of affected browser(s),operating system(s), npm, node and ngrx:

npm -v v5.3.0
node -v v8.1.4
@ngrx/store v4.0.0
@ngrx/effects v4.0.1

Other information:

Haven't had a chance to Dif through the source but I'll hop on and help if anyone needs it. I don't mid at all if you reach out.

(moved this issue over from @ngrx/effects issue #171)

@kmaraz
Copy link

kmaraz commented Feb 6, 2020

Hi!, Is this issue solved? I have the latest NgRx and I can replicate this issue in my project. When I change the order, state is undefined. Thanks

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

No branches or pull requests

3 participants