Skip to content

Commit

Permalink
fix: Use service:router routeDidChange instead (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
raido committed Sep 23, 2020
1 parent 7266d6b commit af3a830
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions addon/services/page-title-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let isFastBoot = typeof FastBoot !== 'undefined';
@extends Ember.Service
*/
export default Service.extend({
router: service(),
document: service('-document'),

init() {
Expand All @@ -30,6 +31,9 @@ export default Service.extend({
}
});
}
this.router.on('routeDidChange', () => {
this.scheduleTitleUpdate();
});
},

/**
Expand Down Expand Up @@ -193,18 +197,7 @@ export default Service.extend({
}),

scheduleTitleUpdate() {
let router = getOwner(this).lookup('router:main');
let { activeTransition } = router._routerMicrolib;
if (activeTransition) {
activeTransition.promise.finally(() => {
if (this.isDestroyed) {
return;
}
scheduleOnce('afterRender', this, this._updateTitle);
});
} else {
scheduleOnce('afterRender', this, this._updateTitle);
}
scheduleOnce('afterRender', this, this._updateTitle);
},

toString() {
Expand Down

0 comments on commit af3a830

Please sign in to comment.