Skip to content

Init effect is not triggering other effects #152

@berwyn

Description

@berwyn

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:

@Effect()
init(): Observable<Action> {
  return this.actions$
    .ofType('@ngrx/effects/init')
    .mergeMap(() => Observable.of(doSetup()));
}

Which I converted, based on the migration guide, to:

@Effect()
init(): Observable<Action> {
  return Observable.defer(() => Observable.of(doSetup()));
}

in either case, I have another effect in the same class that's listening for the type returned by doInit:

@Effect()
onSetup(): Observable<Action> {
  return this.actions$
    .ofType(ActionTypes.doSetup)
    .mergeMap(action => {
      // contents elided
    });
}

and this effect is not triggered at all. The action from init is dispatched, but isn't caught by onSetup, 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.

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