Skip to content

Commit

Permalink
fix(router): enable loadChildren with function in aot (#13909)
Browse files Browse the repository at this point in the history
Closes #11075
  • Loading branch information
Dzmitry Shylovich authored and mhevery committed Jan 19, 2017
1 parent 7ffd105 commit 2af5862
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions modules/@angular/router/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {Type} from '@angular/core';
import {NgModuleFactory, Type} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {PRIMARY_OUTLET} from './shared';
import {UrlSegment, UrlSegmentGroup} from './url_tree';
Expand Down Expand Up @@ -310,7 +310,8 @@ export type ResolveData = {
* See {@link Routes} for more details.
* @stable
*/
export type LoadChildrenCallback = () => Type<any>| Promise<Type<any>>| Observable<Type<any>>;
export type LoadChildrenCallback = () =>
Type<any>| NgModuleFactory<any>| Promise<Type<any>>| Observable<Type<any>>;

/**
* @whatItDoes The type of `loadChildren`.
Expand Down
6 changes: 4 additions & 2 deletions modules/@angular/router/src/utils/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {NgModuleFactory} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {fromPromise} from 'rxjs/observable/fromPromise';
import {of } from 'rxjs/observable/of';
Expand Down Expand Up @@ -126,7 +127,8 @@ export function andObservables(observables: Observable<Observable<any>>): Observ
return every.call(merged$, (result: any) => result === true);
}

export function wrapIntoObservable<T>(value: T | Promise<T>| Observable<T>): Observable<T> {
export function wrapIntoObservable<T>(value: T | NgModuleFactory<T>| Promise<T>| Observable<T>):
Observable<T> {
if (value instanceof Observable) {
return value;
}
Expand All @@ -136,4 +138,4 @@ export function wrapIntoObservable<T>(value: T | Promise<T>| Observable<T>): Obs
}

return of (value);
}
}
2 changes: 1 addition & 1 deletion tools/public_api_guard/router/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export interface ExtraOptions {
export declare type LoadChildren = string | LoadChildrenCallback;

/** @stable */
export declare type LoadChildrenCallback = () => Type<any> | Promise<Type<any>> | Observable<Type<any>>;
export declare type LoadChildrenCallback = () => Type<any> | NgModuleFactory<any> | Promise<Type<any>> | Observable<Type<any>>;

/** @stable */
export declare class NavigationCancel {
Expand Down

0 comments on commit 2af5862

Please sign in to comment.