Angular / RxJs我应该何时退订`Subscription`
问题: When should I store the Subscription instances and invoke unsubscribe() during the NgOnDestroy life cycle and when can I simply ignore them? 在NgOnDestroy生命周期中,什么时候应该存储 Subscription 实例并调用 unsubscribe() ?什么时候可以忽略它们? Saving all subscriptions introduces a lot of mess into component code. 保存所有订阅会在组件代码中带来很多麻烦。 HTTP Client Guide ignore subscriptions like this: HTTP客户端指南 会忽略这样的订阅: getHeroes() { this.heroService.getHeroes() .subscribe( heroes => this.heroes = heroes, error => this.errorMessage = <any>error); } In the same time Route & Navigation Guide says that: 同时,《 路线与导航指南 》指出: Eventually, we'll