MCPcopy Index your code
hub / github.com/angular/angular / CustomReuseStrategy

Class CustomReuseStrategy

packages/router/test/route_injector_cleanup.spec.ts:63–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61 }
62
63 @Injectable({providedIn: 'root'})
64 class CustomReuseStrategy extends BaseRouteReuseStrategy {
65 storedHandles = new Map<Route, DetachedRouteHandle>();
66 shouldDestroyMap = new Map<Route, boolean>();
67
68 override shouldDetach(route: ActivatedRouteSnapshot): boolean {
69 return (
70 route.routeConfig?.path === 'home' ||
71 route.routeConfig?.path === 'check' ||
72 route.routeConfig?.path === 'child'
73 );
74 }
75
76 override store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle | null): void {
77 if (route.routeConfig?.path && handle) {
78 this.storedHandles.set(route.routeConfig, handle);
79 }
80 }
81
82 override shouldAttach(route: ActivatedRouteSnapshot): boolean {
83 return !!route.routeConfig?.path && !!this.storedHandles.has(route.routeConfig);
84 }
85
86 override retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null {
87 return this.storedHandles.get(route.routeConfig!) || null;
88 }
89
90 retrieveStoredRouteHandles(): DetachedRouteHandle[] {
91 return Array.from(this.storedHandles.values());
92 }
93
94 override shouldDestroyInjector(route: Route): boolean {
95 // Default to true if not specified, so we don't block destruction by default
96 return this.shouldDestroyMap.has(route) ? this.shouldDestroyMap.get(route)! : true;
97 }
98 }
99
100 let router: Router;
101 let strategy: CustomReuseStrategy;

Callers

nothing calls this directly

Calls 1

InjectableInterface · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…