
This reverts commit cf7292fcb1f41bef4bda425c65be169588f357f4. This commit triggered an existing race condition in Google code. More work is needed on the Router to fix this condition before this refactor can land.
23 lines
690 B
TypeScript
23 lines
690 B
TypeScript
import {RouteHandler} from './route_handler';
|
|
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
|
|
import {isPresent, Type} from 'angular2/src/facade/lang';
|
|
|
|
export class AsyncRouteHandler implements RouteHandler {
|
|
/** @internal */
|
|
_resolvedComponent: Promise<any> = null;
|
|
componentType: Type;
|
|
|
|
constructor(private _loader: Function, public data?: {[key: string]: any}) {}
|
|
|
|
resolveComponentType(): Promise<any> {
|
|
if (isPresent(this._resolvedComponent)) {
|
|
return this._resolvedComponent;
|
|
}
|
|
|
|
return this._resolvedComponent = this._loader().then((componentType) => {
|
|
this.componentType = componentType;
|
|
return componentType;
|
|
});
|
|
}
|
|
}
|