简体   繁体   English

在Angular5中完成ngrx动作/效果后如何通知我?

[英]How can I be notified when an ngrx action / effect is complete in Angular5?

In my component, I have 在我的组件中,我有

this.uploadService.onUpload({
  some: data
})

In my uploadService , I have 在我的uploadService ,我有

  onUpload($event: SubmissionFileUpload) {
    this.userDetails$ = this.homeService.getUserDetails();
    this.userDetails$.subscribe(
      res => {
        this.userDetails = res;
      });
    this.store.dispatch(new UploadActions.UploadPresignAction(this.userDetails.jwt, $event));
  }

How can my component be notified when the dispatched action is complete? 分派的动作完成后如何通知我的组件?

We designed our app in this way. 我们以这种方式设计了我们的应用程序。

Fire an action A -> Reducer or effect X listening to that action. 触发动作A->减速器或效果X收听该动作。 X after finishing the job do the needful or fire another action B(Success case) or action C (failure case) that being listened by reducer or effect Y. X完成工作后,做必要的事情或解开减速器或效果Y监听的另一个动作B(成功案例)或动作C(失败案例)。

So in your case Reducer or Effect X/Y changes a state in the store that your component is listening to. 因此,在您的情况下,Reducer或Effect X / Y会更改组件正在侦听的存储中的状态。

In other words, components know only about reading from the store and smart components firing an action too but not taking care of if an action went well or not. 换句话说,组件仅了解从商店读取的信息,而智能组件也触发操作,但不会考虑操作是否顺利。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM