question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docs: Router didTransition usage example uses private "url" property and returns incorrect URLs

See original GitHub issue

https://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:closed
  • Created 5 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rwjbluecommented, Dec 8, 2018
0reactions
rwjbluecommented, Dec 8, 2018

@raido - oh no! Great catch!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ember.Router - 2.14
The Ember.Router class manages the application state and URLs. Refer to the routing guide for documentation.
Read more >
Ember render 404 with Invalid URL Slugs - Stack Overflow
I believe your issue is that when you are trying to transition into a "catch all", Ember.js has no idea what that is....
Read more >
Routing in Ember - Learn web development | MDN
In this article we learn about routing, or URL-based filtering as it is sometimes referred to. We'll use it to provide a unique...
Read more >
ember-source | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >
(PDF) Ember.js Guides The guide for building Ambitious Web ...
55 Bindings, Observers, Computed Properties: What Do I Use When? ... ⁴https://github.com/emberjs/website/ Getting Started Welcome to Ember.js!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found