mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(tree): use destroy cleanup logic from base class (#10740)
Uses the `ngOnDestroy` logic from the `CdkTreeNode` rather than re-implementing it in the `CdkNestedTreeNode`. This is less prone to errors in the future, if we decide to introduce more cleanup logic inside the base class.
This commit is contained in:
committed by
tinayuangao
parent
f023579879
commit
718cee012e
@@ -79,13 +79,12 @@ export class CdkNestedTreeNode<T> extends CdkTreeNode<T> implements AfterContent
|
||||
this.updateChildrenNodes();
|
||||
});
|
||||
this.nodeOutlet.changes.pipe(takeUntil(this._destroyed))
|
||||
.subscribe((_) => this.updateChildrenNodes());
|
||||
.subscribe(() => this.updateChildrenNodes());
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this._clear();
|
||||
this._destroyed.next();
|
||||
this._destroyed.complete();
|
||||
super.ngOnDestroy();
|
||||
}
|
||||
|
||||
/** Add children dataNodes to the NodeOutlet */
|
||||
|
||||
Reference in New Issue
Block a user