Skip to content

Commit

Permalink
avoid RouterService's own router access triggers setup
Browse files Browse the repository at this point in the history
  • Loading branch information
xg-wang committed Sep 20, 2020
1 parent 77b333b commit c6226d0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/@ember/-internals/routing/lib/services/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Transition } from 'router_js';
import EmberRouter, { QueryParam } from '../system/router';
import { extractRouteArgs, resemblesURL, shallowEqual } from '../utils';

const ROUTER = symbol('ROUTER');
const ROUTER = symbol('ROUTER') as string;

let freezeRouteInfo: Function;
if (DEBUG) {
Expand Down Expand Up @@ -79,14 +79,16 @@ export default class RouterService extends Service {
init() {
super.init(...arguments);

this._router.on('routeWillChange', (transition: Transition) => {
const router = getOwner(this).lookup('router:main') as EmberRouter;

router.on('routeWillChange', (transition: Transition) => {
if (DEBUG) {
freezeRouteInfo(transition);
}
this.trigger('routeWillChange', transition);
});

this._router.on('routeDidChange', (transition: Transition) => {
router.on('routeDidChange', (transition: Transition) => {
if (DEBUG) {
freezeRouteInfo(transition);
}
Expand Down

0 comments on commit c6226d0

Please sign in to comment.