fix(bootstrap): swap coreBootstrap() and coreLoadAndBootstrap() arguments

This commit is contained in:
Victor Berchet 2016-05-20 11:18:08 -07:00
parent 3ff20cd7e3
commit f95a604b59
10 changed files with 17 additions and 18 deletions

View File

@ -5,4 +5,4 @@ import {Basic} from './basic';
const appInjector =
ReflectiveInjector.resolveAndCreate(BROWSER_APP_STATIC_PROVIDERS, browserPlatform().injector);
coreBootstrap(appInjector, BasicNgFactory);
coreBootstrap(BasicNgFactory, appInjector);

View File

@ -51,7 +51,7 @@ export function createPlatform(injector: Injector): PlatformRef {
export function assertPlatform(requiredToken: any): PlatformRef {
var platform = getPlatform();
if (isBlank(platform)) {
throw new BaseException('Not platform exists!');
throw new BaseException('No platform exists!');
}
if (isPresent(platform) && isBlank(platform.injector.get(requiredToken, null))) {
throw new BaseException(
@ -78,10 +78,10 @@ export function getPlatform(): PlatformRef {
/**
* Shortcut for ApplicationRef.bootstrap.
* Requires a platform the be created first.
* Requires a platform to be created first.
*/
export function coreBootstrap<C>(injector: Injector,
componentFactory: ComponentFactory<C>): ComponentRef<C> {
export function coreBootstrap<C>(componentFactory: ComponentFactory<C>,
injector: Injector): ComponentRef<C> {
var appRef: ApplicationRef = injector.get(ApplicationRef);
return appRef.bootstrap(componentFactory);
}
@ -89,10 +89,10 @@ export function coreBootstrap<C>(injector: Injector,
/**
* Resolves the componentFactory for the given component,
* waits for asynchronous initializers and bootstraps the component.
* Requires a platform the be created first.
* Requires a platform to be created first.
*/
export function coreLoadAndBootstrap(injector: Injector,
componentType: Type): Promise<ComponentRef<any>> {
export function coreLoadAndBootstrap(componentType: Type,
injector: Injector): Promise<ComponentRef<any>> {
var appRef: ApplicationRef = injector.get(ApplicationRef);
return appRef.run(() => {
var componentResolver: ComponentResolver = injector.get(ComponentResolver);

View File

@ -25,7 +25,6 @@ import {
Component,
ReflectiveInjector,
coreLoadAndBootstrap,
coreBootstrap,
PlatformRef,
createPlatform,
disposePlatform,
@ -114,8 +113,8 @@ export function main() {
}, 1);
var app = createApplication(
[{provide: APP_INITIALIZER, useValue: () => completer.promise, multi: true}]);
coreLoadAndBootstrap(app.injector, MyComp6)
.then((compRef) => {
coreLoadAndBootstrap(MyComp6, app.injector)
.then(_ => {
expect(initializerDone).toBe(true);
async.done();
});

View File

@ -11,5 +11,5 @@ class MyApp {
var platform = createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PLATFORM_PROVIDERS));
var appInjector = ReflectiveInjector.resolveAndCreate([BROWSER_APP_STATIC_PROVIDERS, appProviders],
platform.injector);
coreLoadAndBootstrap(appInjector, MyApp);
coreLoadAndBootstrap(MyApp, appInjector);
// #enddocregion

View File

@ -102,5 +102,5 @@ export function bootstrap(
var appInjector = ReflectiveInjector.resolveAndCreate(
[BROWSER_APP_PROVIDERS, isPresent(customProviders) ? customProviders : []],
browserPlatform().injector);
return coreLoadAndBootstrap(appInjector, appComponentType);
return coreLoadAndBootstrap(appComponentType, appInjector);
}

View File

@ -23,5 +23,5 @@ export function bootstrapApp(
var appInjector = ReflectiveInjector.resolveAndCreate(
[WORKER_APP_APPLICATION_PROVIDERS, isPresent(customProviders) ? customProviders : []],
workerAppPlatform().injector);
return coreLoadAndBootstrap(appInjector, appComponentType);
return coreLoadAndBootstrap(appComponentType, appInjector);
}

View File

@ -30,5 +30,5 @@ export function bootstrapStatic(appComponentType: Type,
BROWSER_APP_STATIC_PROVIDERS;
var appInjector =
ReflectiveInjector.resolveAndCreate(appProviders, browserPlatform().injector);
return coreLoadAndBootstrap(appInjector, appComponentType);
return coreLoadAndBootstrap(appComponentType, appInjector);
}

View File

@ -29,7 +29,7 @@ export function bootstrapStaticApp(
var appInjector = ReflectiveInjector.resolveAndCreate(
[WORKER_APP_STATIC_APPLICATION_PROVIDERS, isPresent(customProviders) ? customProviders : []],
workerAppPlatform().injector);
return coreLoadAndBootstrap(appInjector, appComponentType);
return coreLoadAndBootstrap(appComponentType, appInjector);
}
function createMessageBus(zone: NgZone): MessageBus {

View File

@ -214,7 +214,7 @@ export function main() {
ReflectiveInjector.resolveAndCreate([BROWSER_APP_PROVIDERS, testProviders],
platform.injector)
.get(ApplicationRef);
coreLoadAndBootstrap(app.injector, HelloRootCmp)
coreLoadAndBootstrap(HelloRootCmp, app.injector)
.then((ref) => {
ref.destroy();
expect(() => app.tick()).not.toThrow();

View File

@ -22,7 +22,7 @@ void main() {
new Provider(APP_INITIALIZER,
useFactory: initAppThread, multi: true, deps: [NgZone, MessageBus])
], platform.injector);
coreLoadAndBootstrap(appInjector, TodoApp);
coreLoadAndBootstrap(TodoApp, appInjector);
});
}