Skip to content

Commit

Permalink
improve route debug
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Dec 27, 2023
1 parent dc152c1 commit 173e6db
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions ember_debug/route-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Check failure on line 8 in ember_debug/route-debug.js

View workflow job for this annotation

GitHub Actions / Test

Replace `"ember-debug/utils/ember/runloop"` with `'ember-debug/utils/ember/runloop'`
import bound from "ember-debug/utils/bound-method";

Check failure on line 9 in ember_debug/route-debug.js

View workflow job for this annotation

GitHub Actions / Test

Replace `"ember-debug/utils/bound-method"` with `'ember-debug/utils/bound-method'`

const { hasOwnProperty } = Object.prototype;

Expand All @@ -15,32 +16,29 @@ 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();
}

get router() {
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;
}
Expand Down Expand Up @@ -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] });

Check failure on line 203 in ember_debug/route-debug.js

View workflow job for this annotation

GitHub Actions / Test

Replace `·routeHandler.get·||·(function(prop)·{·return·this[prop]·})` with `⏎··········routeHandler.get·||⏎··········function·(prop)·{⏎············return·this[prop];⏎··········}`
controllerName = get.call(routeHandler, 'controllerName') || routeHandler.routeName;

Check failure on line 204 in ember_debug/route-debug.js

View workflow job for this annotation

GitHub Actions / Test

Insert `⏎·········`
controllerFactory = owner.factoryFor
? owner.factoryFor(`controller:${controllerName}`)
: owner._lookupFactory(`controller:${controllerName}`);
Expand Down

0 comments on commit 173e6db

Please sign in to comment.