This changes Angular so that it can be used without reflection (assuming a codegen for injectors). BREAKIKNG CHANGE: - Drops `APP_COMPONENT` provider. Instead, inject `ApplicationRef` and read its `componentTypes` property. - long form bootstrap has changed into the following: ``` var platform = createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PROVIDERS)); var appInjector = ReflectiveInjector.resolveAndCreate([BROWSER_APP_PROVIDERS, appProviders], platform.injector); coreLoadAndBootstrap(appInjector, MyApp); ```
23 lines
770 B
TypeScript
23 lines
770 B
TypeScript
import {MessageBasedPlatformLocation} from './platform_location';
|
|
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
|
import {
|
|
BrowserPlatformLocation
|
|
} from 'angular2/src/platform/browser/location/browser_platform_location';
|
|
import {APP_INITIALIZER, Provider, Injector, NgZone} from 'angular2/core';
|
|
|
|
export const WORKER_RENDER_ROUTER = CONST_EXPR([
|
|
MessageBasedPlatformLocation,
|
|
BrowserPlatformLocation,
|
|
CONST_EXPR(
|
|
new Provider(APP_INITIALIZER,
|
|
{useFactory: initRouterListeners, multi: true, deps: CONST_EXPR([Injector])}))
|
|
]);
|
|
|
|
function initRouterListeners(injector: Injector): () => void {
|
|
return () => {
|
|
let zone = injector.get(NgZone);
|
|
|
|
zone.runGuarded(() => injector.get(MessageBasedPlatformLocation).start());
|
|
};
|
|
}
|