feat(router): add RouterStateCandidate
This commit is contained in:
parent
1f6ade894e
commit
2de1030413
|
@ -1,9 +1,10 @@
|
|||
import { Tree, TreeNode } from './utils/tree';
|
||||
import { UrlSegment } from './url_tree';
|
||||
import { Route } from './config';
|
||||
import { Params, PRIMARY_OUTLET } from './shared';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
import { Type } from '@angular/core';
|
||||
import { Type, ComponentFactory } from '@angular/core';
|
||||
|
||||
/**
|
||||
* The state of the router at a particular moment in time.
|
||||
|
@ -35,6 +36,15 @@ export function createEmptyState(rootComponent: Type): RouterState {
|
|||
return new RouterState(new TreeNode<ActivatedRoute>(activated, []), emptyQueryParams, fragment);
|
||||
}
|
||||
|
||||
export function createEmptyStateCandidate(rootComponent: Type): RouterStateCandidate {
|
||||
const emptyUrl = [new UrlSegment("", {}, PRIMARY_OUTLET)];
|
||||
const emptyParams = {};
|
||||
const emptyQueryParams = {};
|
||||
const fragment = "";
|
||||
const activated = new ActivatedRouteCandidate(emptyUrl, emptyParams, PRIMARY_OUTLET, rootComponent, null);
|
||||
return new RouterStateCandidate(new TreeNode<ActivatedRouteCandidate>(activated, []), emptyQueryParams, fragment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the information about a component loaded in an outlet.
|
||||
*
|
||||
|
@ -53,4 +63,28 @@ export class ActivatedRoute {
|
|||
public params: Observable<Params>,
|
||||
public outlet: string,
|
||||
public component: Type | string) {}
|
||||
}
|
||||
|
||||
export class ActivatedRouteCandidate {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_resolvedComponentFactory: ComponentFactory<any>;
|
||||
|
||||
/** @internal **/
|
||||
_routeConfig: Route;
|
||||
|
||||
constructor(public urlSegments: UrlSegment[],
|
||||
public params: Params,
|
||||
public outlet: string,
|
||||
public component: Type | string,
|
||||
routeConfig: Route) {
|
||||
this._routeConfig = routeConfig;
|
||||
}
|
||||
}
|
||||
|
||||
export class RouterStateCandidate extends Tree<ActivatedRouteCandidate> {
|
||||
constructor(root: TreeNode<ActivatedRouteCandidate>, public queryParams: Params, public fragment: string) {
|
||||
super(root);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue