-
-
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
Init effect is not triggering other effects #152
Comments
duplicated #103 |
I used #103 (and the update to the readme it triggered) to update my code to use In the example given, |
Move the init effect, the one with defer, to the bottom of the file. The sequence matters. I think we have discussed this in #103 |
Same as @maxisam I can confirm, that after moving the init$ with defer to the bottom, applicationInit$ is executed, BUT other actions, dispatched from component, using this.store.dispatch(new MyAction()); are not handled by effects. |
So, I moved the defer and that worked as @maxisam explained, however that only seems to solve effects running in the same class. In my case, I need to kick off effects in multiple classes on init. Do I just need to refactor all of those to run on init themselves? |
@berwyn I was in the same boat as you. So I refactor my code to use initialValue instead since my case is more like filling up initial values. |
With the defer at the end of the classe, it is executed when the application init, but the other effects in the same classe are not triggered when there respective actions are dispatched. |
This issue should be resolved in the latest release of |
The only way I can get this to work with the most current effects @brandonroberts is to use .delay on the .of in the deferred observable |
@brandonroberts the latest (10/24) 4.1.0 version of @ngrx/effects suffers from the same issue; I had to move the |
@felikf have you tried the new need to import it like It should work. |
@maxisam / others: It seems to work when listening for That makes sense, when you take the name |
Maybe you could use the startWith operator? |
In case this helps someone this solved my problem: Changing: import { defer, of } from 'rxjs/index' // suggested by IDE to import { defer, of } from 'rxjs' |
I'm in the process of migrating my app from ngrx 2 -> 4 and I'm having some issues with the init migration.
Previously I had:
Which I converted, based on the migration guide, to:
in either case, I have another effect in the same class that's listening for the type returned by
doInit
:and this effect is not triggered at all. The action from
init
is dispatched, but isn't caught byonSetup
, which is causing my app to stop working :/. There are no errors logged or any other diagnostic information I'm seeing, just the action being dispatched but not caught by the effect.The text was updated successfully, but these errors were encountered: