Skip to content

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

@RobHelgeson

Description

@RobHelgeson

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions