fix(bootstrap): swap coreBootstrap() and coreLoadAndBootstrap() arguments
This commit is contained in:
parent
3ff20cd7e3
commit
f95a604b59
|
@ -5,4 +5,4 @@ import {Basic} from './basic';
|
|||
|
||||
const appInjector =
|
||||
ReflectiveInjector.resolveAndCreate(BROWSER_APP_STATIC_PROVIDERS, browserPlatform().injector);
|
||||
coreBootstrap(appInjector, BasicNgFactory);
|
||||
coreBootstrap(BasicNgFactory, appInjector);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue