Files
Angular-Docs-Cn/modules/angular2/src/web_workers/ui/impl.ts
T

40 lines
1.5 KiB
TypeScript
Raw Normal View History

2015-07-10 16:09:18 -07:00
/*
* This file is the entry point for the main thread
* It takes care of spawning the worker and sending it the initial init message
* It also acts and the messenger between the worker thread and the renderer running on the UI
* thread
*/
import {createInjector} from "./di_bindings";
2015-08-21 12:21:29 -07:00
import {MessageBus, MessageBusSink} from "angular2/src/web_workers/shared/message_bus";
2015-07-10 16:09:18 -07:00
import {createNgZone} from 'angular2/src/core/application_common';
import {Injectable} from 'angular2/di';
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
import {wtfInit} from 'angular2/src/profile/wtf_init';
2015-08-21 12:21:29 -07:00
import {WebWorkerSetup} from 'angular2/src/web_workers/ui/setup';
import {MessageBasedRenderCompiler} from 'angular2/src/web_workers/ui/render_compiler';
import {MessageBasedRenderer} from 'angular2/src/web_workers/ui/renderer';
import {MessageBasedXHRImpl} from 'angular2/src/web_workers/ui/xhr_impl';
2015-07-10 16:09:18 -07:00
/**
* Creates a zone, sets up the DI bindings
* And then creates a new WebWorkerMain object to handle messages from the worker
*/
export function bootstrapUICommon(bus: MessageBus) {
BrowserDomAdapter.makeCurrent();
var zone = createNgZone();
wtfInit();
2015-07-10 16:09:18 -07:00
zone.run(() => {
var injector = createInjector(zone, bus);
// necessary to kick off all the message based components
injector.get(WebWorkerMain);
2015-07-10 16:09:18 -07:00
});
}
@Injectable()
export class WebWorkerMain {
constructor(public renderCompiler: MessageBasedRenderCompiler,
public renderer: MessageBasedRenderer, public xhr: MessageBasedXHRImpl,
public setup: WebWorkerSetup) {}
2015-07-10 16:09:18 -07:00
}