tarsinzer / routerkit

🦩 strict typed angular routes
MIT License
75 stars 8 forks source link

Does this support multi-outlet named outlet routing in Angular? #50

Open jrista opened 3 years ago

jrista commented 3 years ago

Title basically says it all. I've recently been exploring the full capabilities of angular's named router outlets and multi-outlet routing. It is some very powerful stuff, and can allow some very intriguing ways of solving certain authentication problems (i.e. sibling "named" outlets can be routed to, and thus route guarded), potentially solve problems with UI libraries that require certain elements to be placed in certain areas of the page, etc.

Using the Angular router more extensively is becoming more common in my work, and when I instruct and teach Angular architecture. Having support for that with strongly typed routes would be very intriguing.

tarsinzer commented 3 years ago

Hi @jrista

@Andrei0872 contacted me yesterday and offered his help with named outlets matter we are going to discuss the interaction of users with outlets in the near future

in any case, this question is now open, and if you have any suggestions, comments, then I will be glad to discuss them well, or at least form the request as you would like it to be - it would be very useful for us

jrista commented 3 years ago

Thanks for the update, @retarsis. I appreciate the response. I need to get into your lib a bit more, and see how you have done things. I may have some recommendations once I get a chance to do that.

Apologies for the late notice...you caught me on the rare...vacation!

jrista commented 3 years ago

Named outlet routing where multiple routes are active concurrently, may be fairly tricky to support with an object-oriented approach. A multi-route url might be something like:

/some/path/main-route(outletName1:secondary-route-name1//outletName2:secondary-route-name2)

I am not sure how you might support such a thing with a simple object property path. Perhaps some kind of map could be passed, that identifies the names of the outlets and then object paths:

[routerLink]="{primary: some.path.main, outletName1: some.path.secondaryRoute1, outletName2: some.path.secondaryRoute2 }"
tarsinzer commented 3 years ago

@jrista hmmmm interesting

I think we can support this (somehow 😅) but what is important for me now is next:

1) are the outlets work with routerkit now?

As I understand it, the answer is yes, only it is untyped, and we can improve the experience through typing named outlets, right? Correct me if I'm wrong please.

2) do we need to support it as one of the main features?

This question is important because I plan to finish several important killer features, before I release 1.0.0, as a version that is ready for use here and now. And if we need to add this feature, then we may have to stay even longer. But this of course does not mean that we will not add it after. On the other hand, if you have the desire and inspiration to help implement this part, then this question in a sense may disappear because more resources will come, and then we just have to come up with an implementation together.

jrista commented 3 years ago

I would have to do some testing, but I do not believe that MULTI-OUTLET routing would work with named outlets right now. I am not sure about just routing to a single outlet at a time. It is the multi-outlet routing, which happens concurrently (i.e. you route to multiple places that all go to different outlets at once) that I'm wondering about. Can support be added for concurrent multi-outlet routing?

It is a built in feature of the Angular router. It is also a very good way of managing security within angular, when certain pages may display content that has different levels of access control/allowed role/permission requirements. You may display some parts that require a basic access level, while other parts may require a higher level. With multi-outlet routing, you can actually control access via route guards, rather than role/permission/acl checks with *ngIf or similar. Which is a bit more effective, IMO, as it does the check before the app ever even attempts to show the content, which depending on how you configure your routes, could prevent lazy loading in some cases, etc.

Anyway, I think it would be a complex feature to implement, but I do think it is a useful thing to try and implement. As for when...I don't think it necessarily needs to be in version 1.0. It could certainly be added in a later version.

I am currently trying to wrap up a release of one of my own OSS projects, and get another one started. Once those are done, I may get into the source code here and see if I could help implement multi-outlet routing...or, at least, provide some recommendations.

tarsinzer commented 3 years ago

@jrista sounds good to me