【发布时间】:2018-11-22 19:55:38
【问题描述】:
如何让我的 ngrx/store 效果调度一个空操作?我正在运行 Angular 6/rxjs 6:
@Effect()
testEffect$ = this.actions$.ofType(FIRST_ACTION).pipe(
map((x) => {
if (x === y) {
return new SECOND_ACTION;
} else {
fire.some.effect;
return EMPTY;
}
})
);
目前,我收到两个错误:Effect "testEffect$" dispatched an invalid action: [object Object],然后是 TypeError: Actions must have a type property。
我找到了this answer,但它似乎不适用于 ng/rxjs 6。到目前为止,我已经尝试了以下方法(无济于事):
EMPTY、Observable.empty()、Observable.of() 和 Observable.of([])、{ type: 'EMPTY_ACTION' }
任何帮助将不胜感激!我知道我可以使用{ dispatch: false },但实际效果大约有五个结果,其中只有一个不使用动作,所以我宁愿最后一个也返回一些东西。
【问题讨论】:
-
fire.some.effect是什么?是this.store$.dispatch吗? -
@martin - 不,这是一个重新路由:
this.router.navigate(['url']);@cartant - 感谢您的链接,但我已经找到了您的答案,我认为它不适用于 ng 6。至少没有一个你提到的选项对我没有用。