Motivation
This is twofold: DRY on route paths. It would be nice if we only need to define the route path in the Route component without needing it somewhere else. The second reason is that enables a (reusable) component to produce URL paths by receiving the resolve() function, route key, and maybe also the parameter values. Maybe the reusable component can provide the latter. I guess it is implementation-dependent.
Technical Details
- Routes that don't specify the
path property or the value of the path property is a regular expression, then they must specify the template property, which would be a new addition to the Route component.
- Routes that specify the
path property with a string don't need anything extra, but if the template property is given, then the latter wins.
This should start with a global function:
declare function resolve(router: RouterEngine, key: string, paramValues?: Record<string, any>): string;
If the paramValues is not given, the current route parameter values are used (available in RouterEngine.routeStatus) so long the route has matched.
Then, to simplify use, a bound resolve() function should be provided to children of routers and routes via the children snippet.
This brings us to something: The growth of the children parameters. At this point, it should be evident that a single RouterContext and RouteContext argument is best for the children snippets of the components.
Motivation
This is twofold: DRY on route paths. It would be nice if we only need to define the route path in the
Routecomponent without needing it somewhere else. The second reason is that enables a (reusable) component to produce URL paths by receiving theresolve()function, route key, and maybe also the parameter values. Maybe the reusable component can provide the latter. I guess it is implementation-dependent.Technical Details
pathproperty or the value of thepathproperty is a regular expression, then they must specify thetemplateproperty, which would be a new addition to theRoutecomponent.pathproperty with a string don't need anything extra, but if thetemplateproperty is given, then the latter wins.This should start with a global function:
If the
paramValuesis not given, the current route parameter values are used (available inRouterEngine.routeStatus) so long the route has matched.Then, to simplify use, a bound
resolve()function should be provided to children of routers and routes via thechildrensnippet.This brings us to something: The growth of the
childrenparameters. At this point, it should be evident that a singleRouterContextandRouteContextargument is best for thechildrensnippets of the components.