我的效果是:
@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));
});
});
它实际上并没有到达这里(基于console.log)。但是我的减速器获得了适当的状态:
case SubmissionFileActions.LoadSubmissionFiles:
我在做什么错?这是与angular5。
答案 0 :(得分:2)
您应该在应用程序根目录导入中注册效果。 https://github.com/ngrx/platform/blob/master/docs/effects/README.md
@NgModule({
imports: [EffectsModule.forRoot([YourEffects])]
})
export class AppModule {}