feat(router): add events tracking activation of individual routes
* Adds `ChildActivationStart` and `ChildActivationEnd` * Adds test to verify the PreActivation phase of routing
This commit is contained in:

committed by
Alex Rickabaugh

parent
82b067fc40
commit
49cd8513e4
@ -41,14 +41,23 @@ export function shallowEqual(a: {[x: string]: any}, b: {[x: string]: any}): bool
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens single-level nested arrays.
|
||||
*/
|
||||
export function flatten<T>(arr: T[][]): T[] {
|
||||
return Array.prototype.concat.apply([], arr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the last element of an array.
|
||||
*/
|
||||
export function last<T>(a: T[]): T|null {
|
||||
return a.length > 0 ? a[a.length - 1] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifys all booleans in an array are `true`.
|
||||
*/
|
||||
export function and(bools: boolean[]): boolean {
|
||||
return !bools.some(v => !v);
|
||||
}
|
||||
@ -85,6 +94,10 @@ export function waitForMap<A, B>(
|
||||
return map.call(last$, () => res);
|
||||
}
|
||||
|
||||
/**
|
||||
* ANDs Observables by merging all input observables, reducing to an Observable verifying all
|
||||
* input Observables return `true`.
|
||||
*/
|
||||
export function andObservables(observables: Observable<Observable<any>>): Observable<boolean> {
|
||||
const merged$ = mergeAll.call(observables);
|
||||
return every.call(merged$, (result: any) => result === true);
|
||||
|
@ -87,4 +87,15 @@ export class TreeNode<T> {
|
||||
constructor(public value: T, public children: TreeNode<T>[]) {}
|
||||
|
||||
toString(): string { return `TreeNode(${this.value})`; }
|
||||
}
|
||||
|
||||
// Return the list of T indexed by outlet name
|
||||
export function nodeChildrenAsMap<T extends{outlet: string}>(node: TreeNode<T>| null) {
|
||||
const map: {[outlet: string]: TreeNode<T>} = {};
|
||||
|
||||
if (node) {
|
||||
node.children.forEach(child => map[child.value.outlet] = child);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
Reference in New Issue
Block a user