Skip to content

Commit

Permalink
fix: subscription leak in side-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Apr 23, 2017
1 parent 2409577 commit 838f233
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/components/SideMenu/side-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -141,6 +146,8 @@ export class SideMenu implements OnInit, OnDestroy {
}

destroy() {
this.changedActiveSubscription.unsubscribe();
this.changedSubscription.unsubscribe();
this.scrollService.unbind();
this.menuService.destroy();
}
Expand Down

0 comments on commit 838f233

Please sign in to comment.