我有一个监听多个动作并执行一些代码的效果,每个动作可能以不同的顺序分派,我需要捕获第一个和最后一个动作何时分派并在映射发生之前做一些逻辑,这是示例代码:
@Effect({dispatch: false})
updated$ = this.actions$.pipe(
ofType(
actionsType.ACTION1,
actionsType.ACTION2,
actionsType.ACTION3,
actionsType.ACTION4,
),
withLatestFrom(this.store$.pipe(
select((state) => state)
)),
map(([action, state]) => {
let objectMapped: {};
objectMapped = buildSomething(state, action.type);
return objectMapped;
}),
tap( (result: any) => {
// I need to know here when the first and the last action happened to do some extra logic.
})
);
答案 0 :(得分:0)
您可以使用type
的{{1}}属性来检查当前正在执行的操作,以执行某些特定代码。
action