如何收听 NGXS 中的多个操作?
我正在将应用程序从NGRX转换为NGXS。在NGRX中,我可以“聆听”多种动作,并对它们做出适当的反应。如何使用NGXS来实现这一目标?
在ngrx中,我可能有以下内容,
this.actions$.pipe(
ofType(fromCustomers.pageLoaded),
ofType(fromCustomers.pageRefreshed)
)
因为我在ngxs中看到@Action
装饰者可以接受和动作类型的 效果绘制方法时的动作类型。
I'm in the process of converting an application from NgRX to NgXs. In NgRx, I could 'listen' to multiple actions in an effect and react appropriately to them. How can I accomplish this using NgXS?
In NgRx, I may have something like the following in an effect
this.actions$.pipe(
ofType(fromCustomers.pageLoaded),
ofType(fromCustomers.pageRefreshed)
)
I see in NgXs that the @Action
decorator can accept and array of action types, but I'm confused on how get the value from the multiple action types when delcaring the method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

在NGXS中,您可以通过
@Action
装饰器监听多个动作,如下所示:In NGXS, you can listen to multiple actions via
@Action
decorator, like the following: