-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from ngx-rocket/bugfix/shell-single-instance
Added custom route reuse strategy
- Loading branch information
Showing
5 changed files
with
42 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
generators/app/templates/src/app/core/route-reusable-strategy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy } from '@angular/router'; | ||
|
||
/** | ||
* A route strategy allowing for explicit route reuse. | ||
* Used as a workaround for https://github.com/angular/angular/issues/18374 | ||
* To reuse a given route, add `data: { reuse: true }` to the route definition. | ||
*/ | ||
export class RouteReusableStrategy extends RouteReuseStrategy { | ||
|
||
public shouldDetach(route: ActivatedRouteSnapshot): boolean { | ||
return false; | ||
} | ||
|
||
public store(route: ActivatedRouteSnapshot, detachedTree: DetachedRouteHandle): void { } | ||
|
||
public shouldAttach(route: ActivatedRouteSnapshot): boolean { | ||
return false; | ||
} | ||
|
||
public retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle { | ||
return null; | ||
} | ||
|
||
public shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean { | ||
return (future.routeConfig === curr.routeConfig) || future.data.reuse; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters