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

Add docs for listening to any route change #230

Open
chasenlehara opened this issue May 1, 2019 · 0 comments
Open

Add docs for listening to any route change #230

chasenlehara opened this issue May 1, 2019 · 0 comments

Comments

@chasenlehara
Copy link
Member

chasenlehara commented May 1, 2019

Inspired by @pmoscuzza-tc’s question on Slack:

I created this event listener to listen to changes to the route and then determine what controller to go to.

route.matched.on('change', function(ev, attr) {
    thisController[(attr) ? `${attr} route` : 'route'](route.data);
});

Here is an example of the issue. If we tried to go to the path /cars/details from /cars this will fire that event listener and work. The route for cars would be product and for details that would be action. Now if we then tried to go to /cars/color from /cars/details this will not fire that event listener.

This only seems to fire if the actual route changes, not the path. Is there something I can do that can also detect a path change? I had tried using route.data.on but that did not seem to work.

Someone else asked a similar question recently too.

It looks like we added a private __url event that can be listened to: #80 (comment)

I’d like us to decide if we want to document that (or make another official API), or document another way of accomplishing the same result (as a getter in a DefineMap, with can-value, etc.).

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

No branches or pull requests

1 participant