From bb00dc3426dfeccc179f9a66cc096e6a10787154 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 30 Apr 2017 14:31:22 +0300 Subject: [PATCH] fix: menu service subscription leak + minor refactor --- lib/services/menu.service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/services/menu.service.ts b/lib/services/menu.service.ts index 5cb2947a..684b6917 100644 --- a/lib/services/menu.service.ts +++ b/lib/services/menu.service.ts @@ -35,7 +35,7 @@ export interface MenuItem { active?: boolean; ready?: boolean; - depth?: number; + depth?: string|number; flatIdx?: number; metadata?: any; @@ -72,7 +72,11 @@ export class MenuService { this.buildMenu(); }); - this._scrollSubscription = scrollService.scroll.subscribe((evt) => { + this.subscribe(); + } + + subscribe() { + this._scrollSubscription = this.scrollService.scroll.subscribe((evt) => { this.onScroll(evt.isScrolledDown); }); @@ -478,5 +482,6 @@ export class MenuService { destroy() { this._hashSubscription.unsubscribe(); this._scrollSubscription.unsubscribe(); + this._progressSubscription.unsubscribe(); } }