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

handlers to "*" cover all next handlers to anything #51

Open
Kal-Aster opened this issue Dec 29, 2017 · 4 comments
Open

handlers to "*" cover all next handlers to anything #51

Kal-Aster opened this issue Dec 29, 2017 · 4 comments

Comments

@Kal-Aster
Copy link

Kal-Aster commented Dec 29, 2017

When an handler as added to "*" and then an handler is added to everything else, "*" handlers have priority even I think it's not supposed to be so.

@nenadlukic
Copy link

nenadlukic commented Feb 2, 2018

The order of route definitions is important. As you can see in the hashChange listener, the routes are evaluated in order, and the first match is executed.

for (var i = 0, c = routes.length; i < c; i++) {
    var route = routes[i];
    if (checkRoute(hash, route)) {
        return;
    }
}

So what you need to do probably is to register the wildcard route last.

@Kal-Aster
Copy link
Author

This means that there can be only one listener per route? Wouldn't it be better to allow more routes?

@nenadlukic
Copy link

Hmm, one listener per one route imho makes sense. What's the use case where you want more listeners? You can wrap your listener in another function if you want to do more stuff under one listener.

@Kal-Aster
Copy link
Author

Some use cases could be a function that fires for all routes (and do something useful) and then a separated function (that do something else useful) for any other possible route

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

2 participants