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
{{ message }}
Repository navigation
feat(router): provide RouteConfig object for AuxRoute #4319
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 /bar, when it's in fact a valid config because one is auxiliary. You won't notice this until you scan all the way right through the different options.
Hm.. I understand. But it feels inconsistent otherwise.. Thing is, that other route definitions like Redirect for example, also just introduce another property which is (prolly) used to determine the route definition type. It just made sense to me to introduce such a property for aux route too, while keeping the rest consistent..
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 path (or whatever property comes first) needs to be different.
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 transit spec https://github.com/cognitect/transit-format
these routes presumably will remain small (larger apps would end up using types e.g. new AuxRoute({})) so there won't be any maintainability problems. The type prop also allows for future proof since the value is dynamic and new types (if any) could be added.
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 type property (which I even like more), we don't have to introduce any new APIs.
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 aux: true property first. Then it is more visually apparent at a glance, and still more succinct.
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 aux: true first, it's like having to remember to do new AuxRoute(...). But the convention entails a lot less typing.
I like the idea of having good conventions add clarity. I miss having the ability to use ! and ? in variable names, from Scheme. In Scheme, all predicates had names ending in ? by convention, and all functions that mutate a value had names ending !. There were a lot of smart little conventions that helped make the remembering of crucial details easier. These should be embraced; maybe even a Sublime plug-in could be written to flag the failure to adhere to these conventions.
The nice thing about this convention is that the code will work even if aux: true is not put first. It is not brittle.
Actually, let me amend my recommendation. Adding a type property would be better than aux: true. But I would also add that it should be a convention that the type is entered first, as a best practice.
@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 RouteConfig.
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)/
Activity
0x-r4bbit commentedon Sep 22, 2015
Without thinking about it too much, I'd vote for something like:
btford commentedon Sep 22, 2015
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
/bar, when it's in fact a valid config because one is auxiliary. You won't notice this until you scan all the way right through the different options.0x-r4bbit commentedon Sep 22, 2015
Hm.. I understand. But it feels inconsistent otherwise.. Thing is, that other route definitions like
Redirectfor example, also just introduce another property which is (prolly) used to determine the route definition type. It just made sense to me to introduce such a property for aux route too, while keeping the rest consistent..PatrickJS commentedon Sep 23, 2015
what do you think of a type property?
{type: 'aux'}|{type: 'redirect'}|{type: 'async'}btford commentedon Sep 23, 2015
@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
path(or whatever property comes first) needs to be different.Things that behave similarly should look similar. Things that do not behave similarly should not look similar. This case is the latter.
PatrickJS commentedon Sep 23, 2015
@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
transitspec https://github.com/cognitect/transit-formatthese routes presumably will remain small (larger apps would end up using types e.g.
new AuxRoute({})) so there won't be any maintainability problems. Thetypeprop also allows for future proof since the value is dynamic and new types (if any) could be added.0x-r4bbit commentedon Sep 25, 2015
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
typeproperty (which I even like more), we don't have to introduce any new APIs.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.
Berkana commentedon Sep 25, 2015
@btford the fix is to teach good conventions, and to have people put the
aux: trueproperty first. Then it is more visually apparent at a glance, and still more succinct.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
aux: truefirst, it's like having to remember to donew AuxRoute(...). But the convention entails a lot less typing.I like the idea of having good conventions add clarity. I miss having the ability to use
!and?in variable names, from Scheme. In Scheme, all predicates had names ending in?by convention, and all functions that mutate a value had names ending!. There were a lot of smart little conventions that helped make the remembering of crucial details easier. These should be embraced; maybe even a Sublime plug-in could be written to flag the failure to adhere to these conventions.The nice thing about this convention is that the code will work even if
aux: trueis not put first. It is not brittle.Berkana commentedon Sep 25, 2015
Actually, let me amend my recommendation. Adding a type property would be better than
aux: true. But I would also add that it should be a convention that the type is entered first, as a best practice.gkalpak commentedon Sep 25, 2015
I haven't played with the new router at all (is it still "new" ? :P), but would it make sense to overload the
@RouteConfigdecorator like this:And have the current (most common ?) form be a shortcut. E.g.:
This proposal might not make sense at all, but hey 😐
Berkana commentedon Sep 25, 2015
@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
RouteConfig.btford commentedon Oct 16, 2015
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.
thelgevold commentedon Oct 21, 2015
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)/
btford commentedon Oct 30, 2015
No. More docs forthcoming.
angular-automatic-lock-bot commentedon Sep 7, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.