Alex Rickabaugh 97d1844bfc feat(core): Add a long-form syntax for Angular bootstrapping.
This change adds a syntax for bootstrapping Angular on a page that allows more fine-grained control of the hierarchy created. platform() creates a platform injector (of which there can only be one). From the platform, .application() creates an Angular application including a Zone and all specified application bindings (e.g. for the DOM, HTTP, Compiler, Renderer, etc). At the application level, .bootstrap() will bootstrap the given component into that application.

Closes #3852
2015-09-14 23:37:39 +00:00

40 lines
1.6 KiB
Dart

library angular2.src.web_workers.worker;
import "package:angular2/src/web_workers/shared/isolate_message_bus.dart";
import "package:angular2/src/web_workers/worker/application_common.dart"
show bootstrapWebWorkerCommon;
import "package:angular2/src/core/facade/async.dart" show Future;
import "package:angular2/src/core/facade/lang.dart" show Type, BaseException;
import "package:angular2/src/core/compiler/dynamic_component_loader.dart" show ComponentRef;
import "dart:isolate";
import "dart:async";
import 'dart:core';
/**
* Bootstrapping a Webworker Application
*
* You instantiate the application side by calling bootstrapWebworker from your webworker index
* script.
* You must supply a SendPort for communicating with the UI side in order to instantiate
* the application.
* Other than the SendPort you can call bootstrapWebworker() exactly as you would call
* bootstrap() in a regular Angular application
* See the bootstrap() docs for more details.
*/
Future<ComponentRef> bootstrapWebWorker(
SendPort replyTo, Type appComponentType,
[List<dynamic> componentInjectableBindings = null]) {
ReceivePort rPort = new ReceivePort();
var sink = new WebWorkerMessageBusSink(replyTo, rPort);
var source = new IsolateMessageBusSource(rPort);
IsolateMessageBus bus = new IsolateMessageBus(sink, source);
return bootstrapWebWorkerCommon(
appComponentType, bus, componentInjectableBindings);
}
class WebWorkerMessageBusSink extends IsolateMessageBusSink {
WebWorkerMessageBusSink(SendPort sPort, ReceivePort rPort) : super(sPort) {
sPort.send(rPort.sendPort);
}
}