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

Nested router #10

Open
jamesplease opened this issue Sep 8, 2015 · 0 comments
Open

Nested router #10

jamesplease opened this issue Sep 8, 2015 · 0 comments

Comments

@jamesplease
Copy link
Member

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:

  1. when and where should I fetch data in my app?
  2. when and where should I compose my views to build the interface?
  3. how can I prevent a user from navigating away (say, if some model is unsaved)?
  4. how should links work (and be intercepted) in my application?
  5. how and where should i add transitions in my application?
  6. 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:

  1. is very small
  2. provides hooks to allow for differences between existing routing implementations
  3. 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:

  1. a DSL with custom regex for dynamic segments
  2. 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
  3. Custom sort algorithms (specificity, depth, order added)
  4. Async transitions
  5. A native scrolling option...maybe?
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

1 participant