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

"routeLoaded" just for some nested routes, not for all #57

Closed
frederikhors opened this issue Nov 11, 2019 · 4 comments
Closed

"routeLoaded" just for some nested routes, not for all #57

frederikhors opened this issue Nov 11, 2019 · 4 comments

Comments

@frederikhors
Copy link
Contributor

@ItalyPaleAle, I agree with you about the few (amazing) basic features that make this router great.

For the window.scrollTo(0, 0) problem (#49) your hint to use the new routeLoaded function is great and I'm using it right now like this:

function routeLoaded () {
  window.scrollTo(0, 0);
}

But it works for every underlying route.

And maybe this is a new problem now.

How to use it only for some <Router> (parent) components?

@TorstenDittmann
Copy link
Contributor

Are you using route parameters?

It may be possible, that the routeLoaded() is not firing when a parameter of the url changes.

@ItalyPaleAle
Copy link
Owner

Hey @frederikhors are you trying to listen to routeLoaded for some routes only? If so, you can use the first argument passed to routeLoaded (event) and check for event.component and match it against a list of components you want to execute this for.

@frederikhors
Copy link
Contributor Author

Hey @frederikhors are you trying to listen to routeLoaded for some routes only? If so, you can use the first argument passed to routeLoaded (event) and check for event.component and match it against a list of components you want to execute this for.

I'm doing it right now. But you also know that it is a bit ugly, right?

ItalyPaleAle added a commit that referenced this issue Nov 17, 2019
This changed the syntax of the route pre-condition functions as well as the data passed to the routeLoaded and conditionsFailed callbacks.

Fixes #44, #57
Breaking change
@ItalyPaleAle
Copy link
Owner

@frederikhors I have just pushed a better fix to master (will be released in version 2.0) that allows you to pass custom objects using the wrap function, even without using route pre-conditions. This is useful to pass custom callbacks that you can execute in the routeLoaded event. See the "Advanced usage" doc :)

freshteapot pushed a commit to freshteapot/svelte-spa-router that referenced this issue Nov 18, 2019
This changed the syntax of the route pre-condition functions as well as the data passed to the routeLoaded and conditionsFailed callbacks.

Fixes ItalyPaleAle#44, ItalyPaleAle#57
Breaking change
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

3 participants