You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@neonstalwart that's not currently possible with strings.
You can add a handler for .addRoute('/foo*') and .addRoute('/foo/bar') then use the .next() feature to get both matches and invoke them.
Because the implementation is based on a routeMap that is keyed on the route expression you can't do this.
However on trick you can do is create two regular expression objects that serialize two different strings but are the same paths. That is a dirty work around though.
What's the actual use case for multiple handlers per path ?
i've written a router that builds on top of this lib to add some more features - e.g. you can remove a route or you can generate an href from a route with an object to help fill in the params, etc. my use case only came about for some tests i'm writing for that router. i was testing the remove capability by adding 2 handlers for the same route, removing one of them and then testing that only one of them gets called.
i could try to make up some really compelling scenarios where having 2 handlers or removing a route might be useful but in all honesty i haven't had a need for either of those yet so i'm not concerned about trying to support a feature that i don't even use. this is why i opened this issue as a question - if it's not something worth doing, i'm ok with that.
should it be possible to add more than one handler for the same path? is that reasonable?
The text was updated successfully, but these errors were encountered: