Shamoon
Shamoon

Reputation: 43619

My ngrx effect won't fire an action

My effect is:

  @Effect()
  loadSubmissionFiles$: Observable<Action> = this.actions$
    .instanceOf(SubmissionFileActions.LoadSubmissionFiles)
    .switchMap(
      action => {
        console.log('action', action)
        var queryParams = action.deliverableTransactionId ? action.deliverableTransactionId : null;
        return this.submissionFileHttpService.loadSubmissionFiles(queryParams)
          .map(
            (res) => {
              return new SubmissionFileActions.LoadSubmissionFilesSuccess(res);
            })
          .catch((err) => {
            return Observable.of(new SubmissionFileActions.LoadSubmissionFilesFailure(err));
          });
      });

It doesn't actually get here (based on the console.log). But my reducer gets the the appropriate state:

case SubmissionFileActions.LoadSubmissionFiles:

What am I doing wrong? This is with angular5.

Upvotes: 0

Views: 297

Answers (1)

Ren&#233; Winkler
Ren&#233; Winkler

Reputation: 7088

You should register the Effects in your application root imports. https://github.com/ngrx/platform/blob/master/docs/effects/README.md

@NgModule({
 imports: [EffectsModule.forRoot([YourEffects])]
})
export class AppModule {}

Upvotes: 2

Related Questions