Angular's popular UI-Router, Angular v2's router, Ember's router, and the wildly popular React Router are similar in that they're all nested routers, which means that the routes are hierarchal. They're also similar in that they implement their router as a hierarchal state machine.
I believe that this algorithm has become so popular because of how tremendously useful it is. When planning the majority (all?) of my web applications these days, nested routers provide the solution to many of the toughest questions when building an application, including:
- when and where should I fetch data in my app?
- when and where should I compose my views to build the interface?
- how can I prevent a user from navigating away (say, if some model is unsaved)?
- how should links work (and be intercepted) in my application?
- how and where should i add transitions in my application?
- when do I encode a user's location into the URL bar and history?
I've done much research on routers, and have begun work on a standalone router that:
- is very small
- provides hooks to allow for differences between existing routing implementations
- is much faster than every existing router (this is a little irrelevant, 'cause slow route matching is prob. never a bottleneck in anyone's app)
Some features:
- a DSL with custom regex for dynamic segments
- Substate features, not pubsub hooks. Substate hooks allow for contextual (per route) handling, like nested 404 pages, whereas pubsub hooks are like global configuration which is less powerful and more annoying to work with
- Custom sort algorithms (specificity, depth, order added)
- Async transitions
- A native scrolling option...maybe?
Angular's popular UI-Router, Angular v2's router, Ember's router, and the wildly popular React Router are similar in that they're all nested routers, which means that the routes are hierarchal. They're also similar in that they implement their router as a hierarchal state machine.
I believe that this algorithm has become so popular because of how tremendously useful it is. When planning the majority (all?) of my web applications these days, nested routers provide the solution to many of the toughest questions when building an application, including:
I've done much research on routers, and have begun work on a standalone router that:
Some features: