Skip to content

Commit af3d6bf

Browse files
authored
Merge pull request #17637 from luxferresum/cleanup_router
Cleanup router a tiny little bit
2 parents a6ef7cd + 82a7e36 commit af3d6bf

File tree

1 file changed

+30
-23
lines changed
  • packages/@ember/-internals/routing/lib/system

1 file changed

+30
-23
lines changed

packages/@ember/-internals/routing/lib/system/router.ts

+30-23
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ interface OutletState {
248248
outlets: NestedOutletState;
249249
}
250250

251+
interface EngineInstance extends Owner {
252+
boot(): void;
253+
destroy(): void;
254+
}
255+
251256
export interface QueryParam {
252257
prop: string;
253258
urlKey: string;
@@ -280,6 +285,27 @@ class EmberRouter extends EmberObject {
280285
rootURL!: string;
281286
_routerMicrolib!: Router<Route>;
282287

288+
currentURL: string | null = null;
289+
currentRouteName: string | null = null;
290+
currentPath: string | null = null;
291+
292+
_qpCache = Object.create(null);
293+
_qpUpdates = new Set();
294+
295+
_handledErrors = new Set();
296+
_engineInstances: { [name: string]: { [id: string]: EngineInstance } } = Object.create(null);
297+
_engineInfoByRoute = Object.create(null);
298+
299+
constructor() {
300+
super(...arguments);
301+
302+
if (EMBER_ROUTING_ROUTER_SERVICE) {
303+
this.currentRoute = null;
304+
}
305+
306+
this._resetQueuedQueryParameterChanges();
307+
}
308+
283309
_initRouterJs() {
284310
let location = get(this, 'location');
285311
let router = this;
@@ -501,25 +527,6 @@ class EmberRouter extends EmberObject {
501527
return new EmberRouterDSL(null, options);
502528
}
503529

504-
init() {
505-
this._super(...arguments);
506-
507-
this.currentURL = null;
508-
this.currentRouteName = null;
509-
this.currentPath = null;
510-
511-
if (EMBER_ROUTING_ROUTER_SERVICE) {
512-
this.currentRoute = null;
513-
}
514-
515-
this._qpCache = Object.create(null);
516-
this._qpUpdates = new Set();
517-
this._resetQueuedQueryParameterChanges();
518-
this._handledErrors = new Set();
519-
this._engineInstances = Object.create(null);
520-
this._engineInfoByRoute = Object.create(null);
521-
}
522-
523530
/*
524531
Resets all pending query parameter changes.
525532
Called after transitioning to a new route
@@ -592,7 +599,7 @@ class EmberRouter extends EmberObject {
592599
}
593600

594601
let routeInfos = this._routerMicrolib.currentRouteInfos;
595-
let route;
602+
let route: Route | undefined;
596603
let defaultParentState: OutletState;
597604
let liveRoutes = null;
598605

@@ -825,8 +832,8 @@ class EmberRouter extends EmberObject {
825832
}
826833

827834
_setupLocation() {
828-
let location = get(this, 'location');
829-
let rootURL = get(this, 'rootURL');
835+
let location = this.location;
836+
let rootURL = this.rootURL;
830837
let owner = getOwner(this);
831838

832839
if ('string' === typeof location && owner) {
@@ -1732,7 +1739,7 @@ EmberRouter.reopenClass({
17321739
},
17331740

17341741
_routePath(routeInfos: PrivateRouteInfo[]) {
1735-
let path = [];
1742+
let path: string[] = [];
17361743

17371744
// We have to handle coalescing resource names that
17381745
// are prefixed with their parent's names, e.g.

0 commit comments

Comments
 (0)