【发布时间】:2019-06-11 17:41:22
【问题描述】:
我是 Ngrx 的新手,在使用 Ngrx 效果设置轮询时遇到问题
我已经尝试过How to do http polling in ngrx effect 中提到的答案,但这似乎并没有按我的解决方案预期的那样工作。我有一种感觉,这可能是因为我的退货声明
LoadProcessesByUser$: Observable<Action> = this.actions$.pipe(
ofType(AppActions.LoadProcessesByUser),
switchMap(() => {
interval(100).pipe(
startWith(0),
mapTo(this.actions$)
);
return this.apiService.getUserProcesses(this.userService.user.lanId).pipe(
map(result => new LoadProcessesSuccess(result)),
catchError(error => of(new LoadFailure(error)))
);
})
);
我希望看到此效果每 100 毫秒被调用一次,但看起来,它只在我调度 LoadProcessByUser() 时才被调用
请注意;我希望此轮询在应用程序的整个生命周期内一直运行。
谢谢
【问题讨论】:
标签: angular ngrx polling ngrx-effects