Skip to content

Instantly share code, notes, and snippets.

@nathan-lapinski
Last active December 29, 2018 15:45
Show Gist options
  • Save nathan-lapinski/4a7440f2df7f55ddee6b153bee906100 to your computer and use it in GitHub Desktop.
Save nathan-lapinski/4a7440f2df7f55ddee6b153bee906100 to your computer and use it in GitHub Desktop.
The router's default reuse strategy
/**
* Does not detach any subtrees. Reuses routes as long as their route config is the same.
*/
export class DefaultRouteReuseStrategy implements RouteReuseStrategy {
shouldDetach(route: ActivatedRouteSnapshot): boolean { return false; }
store(route: ActivatedRouteSnapshot, detachedTree: DetachedRouteHandle): void {}
shouldAttach(route: ActivatedRouteSnapshot): boolean { return false; }
retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle|null { return null; }
shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {
return future.routeConfig === curr.routeConfig;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment