angular - 何时取消订阅 `route.params` observable

标签 angular rxjs observable

我不知道在什么情况下应该取消订阅 route.params observable。

  • Angular 文档说我们不需要取消订阅。

那么我应该取消订阅的用例是什么?

最佳答案

据此answer ,除非是动态组件或子组件,否则不应订阅:

Unsubscribe from the ActivatedRoute observables like route.params if they are subscribed inside a nested (Added inside tpl with the component selector) or dynamic component as they may be subscribed many times as long as the parent/host component exists. No need to unsubscribe from them in other scenarios as mentioned in the quote above from Routing & Navigation docs.

关于angular - 何时取消订阅 `route.params` observable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51821986/

相关文章:

javascript - RxJS如何实现flatMapLatest 二

javascript - 将 RxJS 与 filter(Boolean) 一起用于查询?

rxjs 不发出直到值不为空

java - 如何将可变参数传递给观察者?

Angular 6 创建一个基本组件并在 html 中调用它的父组件?

angular - Angular 2 中的导入接口(interface)

angular - HttpEventType.UploadProgress 并非来自 Asp.NET MVC

javascript - 在使用 Angular 将项目添加到数组之前,如何检查它是否已经在数组中?

angular - 类 'AuthGaurd' 错误地实现了接口(interface) CanActivate

angular - Fork 加入两个 firebase observable