我正在看这个使用untilDestroyed的代码片段:
this.control.valueChanges.pipe(untilDestroyed(this)).subscribe(c => {
this.update.emit(c);
});
}
Angular是否会自动取消订阅可用于组件销毁的FormControl.valueChanges
,或者我们是否需要运营商?
我问的部分原因是我的理解是Angular会自动取消订阅模板表达式中使用的Observable,所以我想也许它可能有一种“魔术”的方式来为FormControl实例做这件事吗?
您应该取消订阅ngOnDestroy
组件回调。
由于流永远不会关闭,订阅将保留。