@@ -5,7 +5,8 @@ import classify from 'ember-debug/utils/classify';
5
5
import dasherize from 'ember-debug/utils/dasherize' ;
6
6
7
7
import Ember from 'ember-debug/utils/ember' ;
8
- import { later } from 'ember-debug/utils/ember/runloop' ;
8
+ import { _backburner , later } from 'ember-debug/utils/ember/runloop' ;
9
+ import bound from 'ember-debug/utils/bound-method' ;
9
10
10
11
const { hasOwnProperty } = Object . prototype ;
11
12
@@ -15,32 +16,29 @@ export default class RouteDebug extends DebugPort {
15
16
super . init ( ) ;
16
17
this . __currentURL = this . currentURL ;
17
18
this . __currentRouter = this . router ;
18
- this . observer = setInterval ( ( ) => {
19
- if ( this . __currentURL !== this . currentURL ) {
20
- this . sendCurrentRoute ( ) ;
21
- this . __currentURL = this . currentURL ;
22
- }
23
- if ( this . __currentRouter !== this . router ) {
24
- this . _cachedRouteTree = null ;
25
- this . __currentRouter = this . router ;
26
- }
27
- } , 150 ) ;
19
+ _backburner . on ( 'end' , bound ( this , this . checkForUpdate ) ) ;
20
+ }
21
+
22
+ checkForUpdate ( ) {
23
+ if ( this . __currentURL !== this . currentURL ) {
24
+ this . sendCurrentRoute ( ) ;
25
+ this . __currentURL = this . currentURL ;
26
+ }
27
+ if ( this . __currentRouter !== this . router ) {
28
+ this . _cachedRouteTree = null ;
29
+ this . __currentRouter = this . router ;
30
+ }
28
31
}
29
32
30
33
willDestroy ( ) {
31
- clearInterval ( this . observer ) ;
34
+ _backburner . off ( 'end' , bound ( this , this . checkForUpdate ) ) ;
32
35
super . willDestroy ( ) ;
33
36
}
34
37
35
38
get router ( ) {
36
39
return this . namespace ?. owner . lookup ( 'router:main' ) ;
37
40
}
38
41
39
- get applicationController ( ) {
40
- const container = this . namespace ?. owner ;
41
- return container . lookup ( 'controller:application' ) ;
42
- }
43
-
44
42
get currentPath ( ) {
45
43
return this . namespace ?. owner . router . currentPath ;
46
44
}
@@ -113,7 +111,7 @@ export default class RouteDebug extends DebugPort {
113
111
}
114
112
if ( className === fullName ) {
115
113
// full name returned as is - this resolver does not look for the module.
116
- className = className . replace ( new RegExp ( `^${ type } \ :` ) , '' ) ;
114
+ className = className . replace ( new RegExp ( `^${ type } :` ) , '' ) ;
117
115
} else if ( className ) {
118
116
// Module exists and found
119
117
className = className . replace (
@@ -202,7 +200,13 @@ function buildSubTree(routeTree, route) {
202
200
controllerClassName = '(unresolved)' ;
203
201
templateName = '(unresolved)' ;
204
202
} else {
205
- controllerName = routeHandler . controllerName || routeHandler . routeName ;
203
+ const get =
204
+ routeHandler . get ||
205
+ function ( prop ) {
206
+ return this [ prop ] ;
207
+ } ;
208
+ controllerName =
209
+ get . call ( routeHandler , 'controllerName' ) || routeHandler . routeName ;
206
210
controllerFactory = owner . factoryFor
207
211
? owner . factoryFor ( `controller:${ controllerName } ` )
208
212
: owner . _lookupFactory ( `controller:${ controllerName } ` ) ;
0 commit comments