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
feat(router): provide RouteConfig object for AuxRoute #4319
Comments
Without thinking about it too much, I'd vote for something like:
|
I think that's a bad option. Consider scanning down a list of routes:
You can't easily tell when scanning this list which ones are auxiliary. For instance, it looks like a mistake that you have two routes with path |
Hm.. I understand. But it feels inconsistent otherwise.. Thing is, that other route definitions like |
what do you think of a type property? |
@gdi2290 I think that suffers the same problem I mentioned in #4319 (comment) Each other type introduces a new "target" (redirectTo, component, etc.) while keeping "path". Aux routes are different because the meaning of their "path" is different. For this reason, I think something about Things that behave similarly should look similar. Things that do not behave similarly should not look similar. This case is the latter. |
@btford ya that's a good point. I also agree @PascalPrecht that it is inconsistent otherwise. The benefit of my proposal is that it's following a javascript convention for the most part. For example, we can look at the GeoJson spec
notice how there are two types here as it's one way to serialize types. We soon realized that this convention may result in maintainability problems when communicating between two typed languages, other than javascript, which lead to the creation of these routes presumably will remain small (larger apps would end up using types e.g. |
I think a more abstracted way is better here. I'm not sure if that's possible, but what if there's a new route definition type that comes up in the future? Do we need to introduce a new property then? This sure depends on the semantics of that particular definition type then, but if we had decided for something like a simple flag, or a I think from a consumer point of view, who doesn't have such a deep understanding of the implementation and semantics itself, will be confused why there's such a special property for the thing called aux route. |
@btford the fix is to teach good conventions, and to have people put the The tension between typing a whole lot more to remove potential confusion and typing less for the folks who use a feature a lot is resolved by this convention. If you have to remember the convention of including I like the idea of having good conventions add clarity. I miss having the ability to use The nice thing about this convention is that the code will work even if |
Actually, let me amend my recommendation. Adding a type property would be better than |
I haven't played with the new router at all (is it still "new" ? :P), but would it make sense to overload the @RouteConfig({
routes: [
{.../* route 1 */...},
{.../* route 2 */...},
...
],
auxRoutes: [
{.../* aux route 1 */...},
{.../* aux route 2 */...},
...
],
whateverTypeOfRoutes: [
{.../* whatever type of route 1 */...},
{.../* whatever type of route 2 */...},
...
]
}) And have the current (most common ?) form be a shortcut. E.g.: @RouteConfig([.../* routes */...])
// is equivalent to (and a shortcut for):
@RouteConfig({
routes: [.../* routes */...]
}) This proposal might not make sense at all, but hey 😐 |
@gkalpak I like that one you suggested. It makes the types explicit, but doesn't require instantiation to be done by the user at the time something is passed into |
I'm not opposed to @gkalpak's suggestion, but it seems quite verbose. For now, I'm going to go with:
We can always revisit the name later if it proves too confusing. |
Are aux routes akin to named sub views in UI-router? With the proposed solution, the confusing part for me is that it's not immediately clear how the aux routes relate to the primary route from the router definition alone. I was thinking about the following as an alternative syntax:
I guess my point is that I am not seeing the need to distinguish between aux vs "regular" routes since any route could potentially serve both purposes. Basically any route can be configured to be a standalone route or a "named view" route if it's added to the outlets array. Assuming the urls would still be the same format as in the Angular connect presentation where the sub views are () parameters to the primary: /primary/(named-view-1)...(named-view-n)/ |
No. More docs forthcoming. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Right now, you must do:
To use auxiliary routes. We should provide a more ES5-friendly version like:
Or:
I'm open to suggestions.
The text was updated successfully, but these errors were encountered: