From 718cee012e0b7363549dd95e8467526554ec1e1d Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Wed, 11 Apr 2018 19:31:04 +0200 Subject: [PATCH] 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. --- src/cdk/tree/nested-node.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cdk/tree/nested-node.ts b/src/cdk/tree/nested-node.ts index 4d61bb2c4d0..781dcb71b73 100644 --- a/src/cdk/tree/nested-node.ts +++ b/src/cdk/tree/nested-node.ts @@ -79,13 +79,12 @@ export class CdkNestedTreeNode extends CdkTreeNode 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 */