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
Thinking about the limitations that v1 carries when trying to fulfill #30, I have realized that, in this particular case for this particular library it might be a good idea to get rid of the "router" concept.
Since this library will simultaneously match any number of routes if their conditions are met, I wonder if the "router" concept is needed at all. After all, the router's main job is to centralize routing. But for what purpose? Most other routers do this to ensure only one route matches, or at least this is what I believe they do. Since this library is not doing this, why keep the router around?
Proposal
Eliminate the Router component and the RouterEngine class.
Create a RouteEngine class with the route-matching logic.
Create a new RoutingContext component to collect route-matching together and enable fallback content.
Explained in words: Migrate the route-matching logic to the route itself, then have routes report route matching status to RoutingContext. RoutingContext is used to trigger fallback content and to provide route status information via its children snippet for people wanting it. Routes also inherit the router's basePath functionality.
RoutingContext will also be needed to enable DPUI, which might require a separation of the DPUI functionality into a new, simpler component where we only specify the route's key. All route matching logic is omitted.
Up to this point, RoutingContext can be optional. Only add if fallback content or DPUI is needed, or if we want/need centralized route-matching data collection.
Potential Problems
RouterTrace needs to be completely reinvented. I suppose it will have to trace routing contexts instead, but its router traversal feature is a goner. Will an extra RouteTrace component be needed to traverse the routing hierarchy? I'm not envisioning how these would look like.
Creating routes via JavaScript will become more complex. Routes will no longer be just data that lives in the router's state since there will be no router. Furthermore, creating a route in code will still require a markup counterpart.
Thinking about the limitations that v1 carries when trying to fulfill #30, I have realized that, in this particular case for this particular library it might be a good idea to get rid of the "router" concept.
Since this library will simultaneously match any number of routes if their conditions are met, I wonder if the "router" concept is needed at all. After all, the router's main job is to centralize routing. But for what purpose? Most other routers do this to ensure only one route matches, or at least this is what I believe they do. Since this library is not doing this, why keep the router around?
Proposal
Routercomponent and theRouterEngineclass.RouteEngineclass with the route-matching logic.RoutingContextcomponent to collect route-matching together and enable fallback content.basePath, plus any additional matched segments from parent routes (to fulfill Make Route components contribute their path contextually, like Router components #30).Explained in words: Migrate the route-matching logic to the route itself, then have routes report route matching status to
RoutingContext.RoutingContextis used to trigger fallback content and to provide route status information via its children snippet for people wanting it. Routes also inherit the router'sbasePathfunctionality.RoutingContextwill also be needed to enable DPUI, which might require a separation of the DPUI functionality into a new, simpler component where we only specify the route's key. All route matching logic is omitted.Up to this point,
RoutingContextcan be optional. Only add if fallback content or DPUI is needed, or if we want/need centralized route-matching data collection.Potential Problems
RouterTraceneeds to be completely reinvented. I suppose it will have to trace routing contexts instead, but its router traversal feature is a goner. Will an extraRouteTracecomponent be needed to traverse the routing hierarchy? I'm not envisioning how these would look like.Creating routes via JavaScript will become more complex. Routes will no longer be just data that lives in the router's state since there will be no router. Furthermore, creating a route in code will still require a markup counterpart.