Skip to content

Commit

Permalink
Run service teardown code in willDestroy() (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeAstapov authored Apr 6, 2021
1 parent 9d494b5 commit 20e1642
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions addon/services/router-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -105,7 +103,7 @@ class RouterScroll extends Service {
window.cancelAnimationFrame(callbackRequestId);
}

super.destroy(...arguments);
super.willDestroy(...arguments);
}

/**
Expand Down

0 comments on commit 20e1642

Please sign in to comment.