我几乎可以肯定我应该,但我没有找到有关Redux文档的任何具体信息.我的大多数Angular组件中的模式是我订阅/取消订阅Redux商店,如:
import { Component,OnInit } from '@angular/core'; @Component({ moduleId: module.id,selector: 'selector',templateUrl: 'name.component.html' }) export class ComponentNameComponent implements OnInit { private unsubscribe : Function; constructor(@Inject(AppStore) private store: Store<AppState>) {} ngOnInit() { this.unsubscribe = this.store.subscribe ( ()=>{ this.updateFromState(); }); } // Is unsubscribing onDestroy necessary? ngOnDestroy(){ this.unsubscribe(); } this.updateFromState(){ // ... } }
所以我想知道我是否应该总是取消订阅商店,如果我没有,会发生什么.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。