Skip to content

Commit 838f233

Browse files
committed
fix: subscription leak in side-menu
1 parent 2409577 commit 838f233

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/components/SideMenu/side-menu.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ export class SideMenu implements OnInit, OnDestroy {
5757
private $resourcesNav: any;
5858
private $scrollParent: any;
5959

60+
private changedActiveSubscription;
61+
private changedSubscription;
62+
6063
constructor(
6164
elementRef:ElementRef,
6265
private scrollService:ScrollService,
@@ -71,8 +74,10 @@ export class SideMenu implements OnInit, OnDestroy {
7174

7275
this.options = optionsService.options;
7376

74-
this.menuService.changedActiveItem.subscribe((evt) => this.changed(evt));
75-
this.menuService.changed.subscribe((evt) => this.detectorRef.detectChanges());
77+
this.changedActiveSubscription = this.menuService.changedActiveItem.subscribe((evt) => this.changed(evt));
78+
this.changedSubscription = this.menuService.changed.subscribe((evt) => {
79+
this.detectorRef.detectChanges()
80+
});
7681
}
7782

7883
changed(item) {
@@ -141,6 +146,8 @@ export class SideMenu implements OnInit, OnDestroy {
141146
}
142147

143148
destroy() {
149+
this.changedActiveSubscription.unsubscribe();
150+
this.changedSubscription.unsubscribe();
144151
this.scrollService.unbind();
145152
this.menuService.destroy();
146153
}

0 commit comments

Comments
 (0)