erikringsmuth / app-router

Router for Web Components
https://erikringsmuth.github.io/app-router/
MIT License
610 stars 83 forks source link

Yield and regions #100

Closed dbismut closed 9 years ago

dbismut commented 9 years ago

I come from Meteor Iron-Router, which allows to inject templates in different regions depending on the route. The whole routing process is declared in javascript code though.

I don't know if I'm misusing app-router, but following the hash-routing example, it looks like each route re-render the whole page (in that case sidebar-layout is reattached to the DOM everytime the route changes).

I'm not sure if this is linked to issue #36, but it would be really nice if there would be a way to tie separate regions of the page to different pages or elements.

Anyway, thanks for the awesome work!

erikringsmuth commented 9 years ago

The shadow DOM has the <content> tag which is very similar to yield. http://w3c.github.io/webcomponents/spec/shadow/#the-content-element

That was the original way I started. https://erikringsmuth.github.io/app-router/#/layouts

I think about half of people do it this way and the other half use multiple layers of routers. If you're using multiple routers you typically want to combine it with onUrlChange to prevent reloading the main part of the page. https://erikringsmuth.github.io/app-router/#/api#onurlchange

I've been holding off on issue 36, but I think I'm going to need to get that one done soon. More and more people are asking for it.

dbismut commented 9 years ago

Hmm. I see, I had overlooked the onUrlChange option to be honest, sorry about this. I've been playing with it a bit, but changing route (for example from /home to /profile) would still calls layout-el domReady, ready, attached, created functions, wouldn't it?

erikringsmuth commented 9 years ago

Yeah, onUrlChange only applies to a single route matching multiple times in a row. The lifecycle functions would still be called when navigating between completely separate routes. #39 would create a single instance of each view and show/hide them.

dbismut commented 9 years ago

Great ok! You can mark this as closed as this looks like a duplicate of #36. Thanks again!

erikringsmuth commented 9 years ago

Closing in favor of https://github.com/erikringsmuth/app-router/issues/36.