Skip to content

Nested router #10

@jamesplease

Description

@jamesplease

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions