Closed ntilwalli closed 7 years ago
Cool, thanks for this. I'll merge this as I don't see any issues with this if you still want to after me asking a question. Are there alternatives to switch-path you see worth investigating first?
I'm not set on switch-path being what is used, just what I built this with via familiarity at the time
Another question, what do you think about having a "bring your own route matcher" only?
makeRouterDriver(history, matchFn)
I haven't investigated alternatives to switch-patch other than writing my own since my needs were pretty basic (reg-ex and array priority ordering for routes) so my function was pretty trivial to write. It does look like solid alternatives exist like https://github.com/rcs/route-parser Also, I liked injection (as opposed to investigating/proposing an alternative) since it's an easy first step which could lead to a switch without getting into the broad discussion of pros and cons of different libs.
I like the idea of "bring your own route matcher" only. If you're cool with it, we can discuss and I can change the PR accordingly.
There is also https://github.com/cerebral/url-mapper for instance.
I think I'm in favor of BYOM (bring your own matcher). If we can get semi decent typings I'm sold. But to be honest, cyclic-router typings suck currently anyways so that shouldn't be too hard.
I've posted an update, critiques welcome.
Thanks @ntilwalli great PR LGTM
Published as v3.0.0
In some cases I've wanted to inject my own matching algorithm (example: I've created a custom reg-ex matcher for routes) and not use switch-path. This PR allows users to inject when they
define
their routes. I'm posting it for discussion and possibly for merge.