如何在NgRx效果中调用另一个调度动作?

问题描述

概述: 用户按下+按钮将购物车中的增加项目添加1.。(this.store.dispatch(CartActions.IncrementCoin({name}))

此后,下一个方法称为
this.store.dispatch(CartActions.updatetotalPrice());

这是更新所有产品的总价,现在我想将第二个动作调用移到一个效果上,因为第二个动作是增量动作的副作用。但是我该怎么做呢?我还没有在网上看到这个问题的答案,所以我在这里问。

这是我要制作的效果,因此它听了incementCoin动作。此后,它需要触发updatetotalPrice操作。我该如何构造?

enter image description here

enter image description here

enter image description here

更新

已实施以下解决方案。现在,此效果可收听5种不同的动作!

enter image description here

解决方法

这可能是实现方式:

public incrementCoin$ = createEffect(() => this.actions$
  .pipe(
    ofType(CartActions.IncrementCoin),map(CartActions.updateTotalPrice)
  )
)