erikringsmuth / app-router

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

Skip activating new route if the current route will not change #67

Closed pdf closed 9 years ago

pdf commented 9 years ago

This avoids reloading and re-rendering unnecessarily. This is particularly useful if you have nested routers where the inner router handles lower url segments and the wrapper handles upper fragments, ie:

<app-router id="outer">
 <app-route path="/" template="/home-page.html"></app-route>
 <app-route path="/user/*" template="/user-page.html"></app-route>
</app-router>

user-page.html:

<app-router id="inner">
 <app-route path="/user/profile" template="/user-profile.html"></app-route>
 <app-route path="/user/stats" template="/user-stats.html"></app-route>
</app-router>

Without this change, navigating between user pages will cause the outer route to activate, followed by the inner route. With this change, navigating between user pages will only trigger the inner routes, and skip re-rendering the containing user-page.html.

pdf commented 9 years ago

Thanks heaps @erikringsmuth, I'll takes some time to hammer on this next week.

benjaminapetersen commented 9 years ago

Oh nice! Will check it out.