refactor: change provide(...) for {provide: ...}
- provide() is deprecated, - {} syntax is required by the offline compiler
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import {
|
||||
DebugNode,
|
||||
getDebugNode,
|
||||
Provider,
|
||||
RootRenderer,
|
||||
NgZone,
|
||||
ApplicationRef
|
||||
|
@ -8,15 +8,11 @@ import {WebWorkerPlatformLocation} from './platform_location';
|
||||
*/
|
||||
export const WORKER_APP_LOCATION_PROVIDERS = [
|
||||
{provide: PlatformLocation, useClass: WebWorkerPlatformLocation},
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: (platformLocation: WebWorkerPlatformLocation, zone: NgZone) => () =>
|
||||
initWorkerLocation(platformLocation, zone),
|
||||
multi: true,
|
||||
deps: [PlatformLocation, NgZone]
|
||||
}
|
||||
{provide: APP_INITIALIZER, useFactory: appInitFnFactory, multi: true, deps: [PlatformLocation, NgZone]}
|
||||
];
|
||||
|
||||
function initWorkerLocation(platformLocation: WebWorkerPlatformLocation, zone: NgZone): Promise<boolean> {
|
||||
return zone.runGuarded(() => platformLocation.init());
|
||||
function appInitFnFactory(platformLocation: WebWorkerPlatformLocation, zone: NgZone): () => Promise<boolean> {
|
||||
return () => {
|
||||
return zone.runGuarded(() => platformLocation.init());
|
||||
};
|
||||
}
|
||||
|
@ -102,17 +102,8 @@ export const WORKER_RENDER_APPLICATION_PROVIDERS: Array<any /*Type | Provider |
|
||||
Testability,
|
||||
EventManager,
|
||||
WebWorkerInstance,
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: (injector => () => initWebWorkerApplication(injector)),
|
||||
multi: true,
|
||||
deps: [Injector]
|
||||
},
|
||||
{
|
||||
provide: MessageBus,
|
||||
useFactory: (instance) => instance.bus,
|
||||
deps: [WebWorkerInstance]
|
||||
}
|
||||
{ provide: APP_INITIALIZER, useFactory: initWebWorkerAppFn, multi: true, deps: [Injector] },
|
||||
{ provide: MessageBus, useFactory: messageBusFactory, deps: [WebWorkerInstance] }
|
||||
];
|
||||
|
||||
export function initializeGenericWorkerRenderer(injector: Injector) {
|
||||
@ -142,6 +133,10 @@ export function bootstrapRender(
|
||||
return PromiseWrapper.resolve(app.get(ApplicationRef));
|
||||
}
|
||||
|
||||
function messageBusFactory(instance: WebWorkerInstance): MessageBus {
|
||||
return instance.bus;
|
||||
}
|
||||
|
||||
function initWebWorkerRenderPlatform(): void {
|
||||
BrowserDomAdapter.makeCurrent();
|
||||
wtfInit();
|
||||
@ -163,19 +158,21 @@ function _document(): any {
|
||||
return getDOM().defaultDoc();
|
||||
}
|
||||
|
||||
function initWebWorkerApplication(injector: Injector): void {
|
||||
var scriptUri: string;
|
||||
try {
|
||||
scriptUri = injector.get(WORKER_SCRIPT);
|
||||
} catch (e) {
|
||||
throw new BaseException(
|
||||
"You must provide your WebWorker's initialization script with the WORKER_SCRIPT token");
|
||||
}
|
||||
function initWebWorkerAppFn(injector: Injector): () => void {
|
||||
return () => {
|
||||
var scriptUri: string;
|
||||
try {
|
||||
scriptUri = injector.get(WORKER_SCRIPT);
|
||||
} catch (e) {
|
||||
throw new BaseException(
|
||||
"You must provide your WebWorker's initialization script with the WORKER_SCRIPT token");
|
||||
}
|
||||
|
||||
let instance = injector.get(WebWorkerInstance);
|
||||
spawnWebWorker(scriptUri, instance);
|
||||
let instance = injector.get(WebWorkerInstance);
|
||||
spawnWebWorker(scriptUri, instance);
|
||||
|
||||
initializeGenericWorkerRenderer(injector);
|
||||
initializeGenericWorkerRenderer(injector);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user