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

Lazy loaded effect initialized multiple times if used in multiple routes #2106

Closed
k-schneider opened this issue Sep 4, 2019 · 0 comments · Fixed by #2164
Closed

Lazy loaded effect initialized multiple times if used in multiple routes #2106

k-schneider opened this issue Sep 4, 2019 · 0 comments · Fixed by #2164

Comments

@k-schneider
Copy link

Expected behavior:

I have a lazy loaded module that imports EffectsModule.forFeature(...) and is accessible from multiple routes within the application. In other words loadChildren is defined for this module multiple times in the app-routing.module.ts file:

/a/b/feature
/c/d/feature

When configured like this ngrxOnInitEffects is triggered multiple times when visiting each route. I would have expected it to only execute one time.

If this is intended what is the suggested approach to ensuring that init code would only run one time?

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):

angular @ 8.1.1
ngrx @ 8.1.0

brandonroberts pushed a commit that referenced this issue Jan 16, 2020
Closes #2106 

BREAKING CHANGE:

BEFORE:

When the effect class was registered, the init action would be dispatched.
If the effect was provided in multiple lazy loaded modules, the init action would be dispatched for every module.

AFTER:

The init action is only dispatched once
The init action is now dispatched based on the identifier of the effect (via ngrxOnIdentifyEffects)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants