-
Notifications
You must be signed in to change notification settings - Fork 0
Description
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
pathproperty or the value of thepathproperty is a regular expression, then they must specify thetemplateproperty, which would be a new addition to theRoutecomponent. - Routes that specify the
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:
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.