From 838f23380ce30f671983c8af107e4aac7ca33c56 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 23 Apr 2017 15:43:56 +0300 Subject: [PATCH] fix: subscription leak in side-menu --- lib/components/SideMenu/side-menu.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/components/SideMenu/side-menu.ts b/lib/components/SideMenu/side-menu.ts index 0838b9c381..66018c23be 100644 --- a/lib/components/SideMenu/side-menu.ts +++ b/lib/components/SideMenu/side-menu.ts @@ -57,6 +57,9 @@ export class SideMenu implements OnInit, OnDestroy { private $resourcesNav: any; private $scrollParent: any; + private changedActiveSubscription; + private changedSubscription; + constructor( elementRef:ElementRef, private scrollService:ScrollService, @@ -71,8 +74,10 @@ export class SideMenu implements OnInit, OnDestroy { this.options = optionsService.options; - this.menuService.changedActiveItem.subscribe((evt) => this.changed(evt)); - this.menuService.changed.subscribe((evt) => this.detectorRef.detectChanges()); + this.changedActiveSubscription = this.menuService.changedActiveItem.subscribe((evt) => this.changed(evt)); + this.changedSubscription = this.menuService.changed.subscribe((evt) => { + this.detectorRef.detectChanges() + }); } changed(item) { @@ -141,6 +146,8 @@ export class SideMenu implements OnInit, OnDestroy { } destroy() { + this.changedActiveSubscription.unsubscribe(); + this.changedSubscription.unsubscribe(); this.scrollService.unbind(); this.menuService.destroy(); }