From 20e16428b6aa2cc5cd82189d14f85d1e8b72d8b4 Mon Sep 17 00:00:00 2001 From: Sergey Astapov Date: Tue, 6 Apr 2021 12:51:53 -0400 Subject: [PATCH] Run service teardown code in willDestroy() (#280) --- addon/services/router-scroll.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addon/services/router-scroll.js b/addon/services/router-scroll.js index 1dae325..9ad4ca7 100644 --- a/addon/services/router-scroll.js +++ b/addon/services/router-scroll.js @@ -5,7 +5,7 @@ import { assert } from '@ember/debug'; import { getOwner } from '@ember/application'; import { scheduleOnce } from '@ember/runloop'; import { addListener, removeListener, sendEvent } from '@ember/object/events'; -import { setupRouter, reset, whenRouteIdle } from 'ember-app-scheduler'; +import { setupRouter, whenRouteIdle } from 'ember-app-scheduler'; let ATTEMPTS = 0; const MAX_ATTEMPTS = 100; // rAF runs every 16ms ideally, so 60x a second @@ -91,9 +91,7 @@ class RouterScroll extends Service { addListener(this.router, 'routeDidChange', this._routeDidChange); } - destroy() { - reset(); - + willDestroy() { removeListener(this.router, 'routeWillChange', this._routeWillChange); removeListener(this.router, 'routeDidChange', this._routeDidChange); @@ -105,7 +103,7 @@ class RouterScroll extends Service { window.cancelAnimationFrame(callbackRequestId); } - super.destroy(...arguments); + super.willDestroy(...arguments); } /**