-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat(Effects): Add root effects init action #473
Conversation
@Inject(ROOT_EFFECTS) rootEffects: any[], | ||
@Optional() storeModule: StoreModule | ||
) { | ||
runner.start(); | ||
store.dispatch({ type: ROOT_EFFECTS_INIT }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be beneath the lines where you add the effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
Why exactly 😄 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dispatching and registering the effects happens synchronously. Moving the dispatch to after registering the effects will give the effects a chance to listen for this new action type.
import { EffectsRunner } from './effects_runner'; | ||
import { EffectSources } from './effect_sources'; | ||
import { ROOT_EFFECTS } from './tokens'; | ||
|
||
export const ROOT_EFFECTS_INIT = '@ngrx/store/root effects init' as '@ngrx/store/root effects init'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename the type string to @ngrx/effects/init
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep you're right, don't know what I was thinking!
Thanks @tdeschryver! |
I am just wondering ... is this supposed to work in feature effects ( If I use:
in root module, it works (it logs). When I use it in feature module, it does not (it does not log). I would need this for feature module though... :) |
Closes #246