fix: subscription leak in side-menu

This commit is contained in:
Roman Hotsiy 2017-04-23 15:43:56 +03:00
parent 2409577e2f
commit 838f23380c
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -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();
}