Docs: Router didTransition usage example uses private "url" property and returns incorrect URLs
See original GitHub issuehttps://emberjs.com/api/ember/3.0/classes/EmberRouter/methods/didTransition?anchor=didTransition — here is an example of using EmberRouter.didTransition()
method by calling this.get(‘url’)
but property url
itself is marked as @private
.
https://github.com/emberjs/ember.js/blob/v3.0.0/packages/ember-routing/lib/system/router.js#L162
Is this a typo and should be public or the example is incorrect?
Another thing I noticed implementing didTransition
to track page views in my app is that I have to wrap call of this.get('url')
in run.scheduleOnce('afterRender')
otherwise it reports URL of the previous route.
Looking deeper into the code - https://github.com/emberjs/ember.js/blob/v3.0.0/packages/ember-routing/lib/system/router.js#L260 <- we’ll find that actually EmberRouter.on('didTransition')
should be used instead of overriding this method like in the example, so then calling this.get('url')
would return correct value.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (6 by maintainers)
I submitted https://github.com/emberjs/ember.js/pull/17313 to fix.
@raido - oh no! Great catch!