refactor(router): don't run the change detection every time an outlet is activated

This commit is contained in:
Victor Berchet
2017-05-17 17:47:34 -07:00
committed by Matias Niemelä
parent 44d48d9d7a
commit 198edb3109
11 changed files with 300 additions and 233 deletions

View File

@ -8,6 +8,7 @@
import {ComponentRef} from '@angular/core';
import {OutletContext} from './router_outlet_context';
import {ActivatedRoute, ActivatedRouteSnapshot} from './router_state';
import {TreeNode} from './utils/tree';
@ -23,6 +24,7 @@ export type DetachedRouteHandle = {};
/** @internal */
export type DetachedRouteHandleInternal = {
contexts: Map<string, OutletContext>,
componentRef: ComponentRef<any>,
route: TreeNode<ActivatedRoute>,
};
@ -36,7 +38,11 @@ export abstract class RouteReuseStrategy {
/** Determines if this route (and its subtree) should be detached to be reused later */
abstract shouldDetach(route: ActivatedRouteSnapshot): boolean;
/** Stores the detached route */
/**
* Stores the detached route.
*
* Storing a `null` value should erase the previously stored value.
*/
abstract store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle|null): void;
/** Determines if this route (and its subtree) should be reattached */