Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transition.urlMethod as a proxy for browser pop state? #278

Open
lougreenwood opened this issue Jan 30, 2019 · 0 comments
Open

transition.urlMethod as a proxy for browser pop state? #278

lougreenwood opened this issue Jan 30, 2019 · 0 comments

Comments

@lougreenwood
Copy link

I'm using the new Ember 3.7 routerService to build the browser's history in js-land for the purposes of showing nav back/forward buttons (think iOS app nav buttons).

One issue I'm facing is when to detect that a routeDidChange was the consequence of a browser back/forward event.

This can be known if I hook into the window.onpopstate event, but unfortunately, this fires after routeDidChange.

So, I've delved into the transition object in the hope of some clue as to whether a specific transition was browser initiated rather than a usual ember routing event.

It seems that transition.urlMethod may be this, from my limited testing it seems that transition.urlMethod will be null when a browser back/forward action triggered the transition and I can therefore use a null value as a indication that some kind of back/forward was used.

I've searched the codebase to see whether this is a safe assumption, but it seems that none of the comments specifically identify this.

So my question is... can I safely use transition.urlMethod to indicate in my code that a transition was not triggered by Ember and therefore is likely a browser-triggered back/forward transition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant