【发布时间】:2018-11-10 18:19:41
【问题描述】:
我正在使用 Angular 6,ngrx/store。我有这样的效果,负责更新东西。取决于我想调度不同动作的一些逻辑。如果我使用switchMap insted 和map 有什么区别?
这是我尝试过的,但它不起作用:
@Effect()
dispathMultipleActions$ = this.actions$.pipe(
ofType(ActionTypes.UpdateSomething),
map(() => {
const actions: Action[] = [];
const array = [1, 2, 3, 4, 5];
array.forEach(item => {
if (item > 3) {
actions.push(new DeleteAction(item));
} else {
actions.push(new ChangeAction(item));
}
});
return actions;
})
);
【问题讨论】:
-
我想你想尝试 switchMap 的函数,该函数返回内部操作的 Observable.concat。这将展平操作列表并考虑顺序。
标签: javascript angular typescript ngrx ngrx-store