diff --git a/ember_debug/route-debug.js b/ember_debug/route-debug.js index f7a0e1ddfd..c8bdbf4d12 100644 --- a/ember_debug/route-debug.js +++ b/ember_debug/route-debug.js @@ -5,7 +5,8 @@ import classify from 'ember-debug/utils/classify'; import dasherize from 'ember-debug/utils/dasherize'; import Ember from 'ember-debug/utils/ember'; -import { later } from 'ember-debug/utils/ember/runloop'; +import { _backburner, later } from "ember-debug/utils/ember/runloop"; +import bound from "ember-debug/utils/bound-method"; const { hasOwnProperty } = Object.prototype; @@ -15,20 +16,22 @@ export default class RouteDebug extends DebugPort { super.init(); this.__currentURL = this.currentURL; this.__currentRouter = this.router; - this.observer = setInterval(() => { - if (this.__currentURL !== this.currentURL) { - this.sendCurrentRoute(); - this.__currentURL = this.currentURL; - } - if (this.__currentRouter !== this.router) { - this._cachedRouteTree = null; - this.__currentRouter = this.router; - } - }, 150); + _backburner.on('end', bound(this, this.checkForUpdate)); + } + + checkForUpdate() { + if (this.__currentURL !== this.currentURL) { + this.sendCurrentRoute(); + this.__currentURL = this.currentURL; + } + if (this.__currentRouter !== this.router) { + this._cachedRouteTree = null; + this.__currentRouter = this.router; + } } willDestroy() { - clearInterval(this.observer); + _backburner.off('end', bound(this, this.checkForUpdate)); super.willDestroy(); } @@ -36,11 +39,6 @@ export default class RouteDebug extends DebugPort { return this.namespace?.owner.lookup('router:main'); } - get applicationController() { - const container = this.namespace?.owner; - return container.lookup('controller:application'); - } - get currentPath() { return this.namespace?.owner.router.currentPath; } @@ -202,7 +200,8 @@ function buildSubTree(routeTree, route) { controllerClassName = '(unresolved)'; templateName = '(unresolved)'; } else { - controllerName = routeHandler.controllerName || routeHandler.routeName; + const get = routeHandler.get || (function(prop) { return this[prop] }); + controllerName = get.call(routeHandler, 'controllerName') || routeHandler.routeName; controllerFactory = owner.factoryFor ? owner.factoryFor(`controller:${controllerName}`) : owner._lookupFactory(`controller:${controllerName}`);