2017-01-26 22:30:42 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# WebWorkers in Angular: Documentation
  
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 22:30:42 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Angular includes native support for writing applications which live in a
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								WebWorker. This document describes how to write applications that take advantage
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								of this feature.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								It also provides a detailed description of the underlying messaging
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								infrastructure that angular uses to communicate between the main process and the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								worker. This infrastructure can be modified by an application developer to
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 22:30:42 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								enable driving an Angular application from an iFrame, different window / tab,
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								server, etc..
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Introduction
  
						 
					
						
							
								
									
										
										
										
											2017-01-26 22:30:42 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								WebWorker support in Angular is designed to make it easy to leverage parallelization in your web application.
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								When you choose to run your application in a WebWorker angular runs both your application's logic and the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								majority of the core angular framework in a WebWorker.
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								By offloading as much code as possible to the WebWorker we keep the UI thread
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								free to handle events, manipulate the DOM, and run animations. This provides a
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								better framerate and UX for applications.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Bootstrapping a WebWorker Application
  
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Bootstrapping a WebWorker application is not much different than bootstrapping a normal application.
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The main difference is that you need to do the bootstrap process on both the worker and render thread.
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 22:30:42 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Unlike in a standard Angular application you don't bootstrap your main component on the render thread.
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Instead you initialize a new application injector with the WORKER_APP_PLATFORM providers and provide the name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								of your WebWorker script. See the example below for details:
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Example
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								To bootstrap Hello World in a WebWorker we do the following in TypeScript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```HTML
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< html >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < head > 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 16:00:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     < script  src = "https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js" > < / script > 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								     < script  src = "https://jspm.io/system @0 .16.js" ></ script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     < script  src = "angular2/web_worker/ui.js" > < / script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < / head > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < body > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < hello-world > < / hello-world > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < script > System . import ( "index" ) < / script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < / body > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / html >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```TypeScript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// index.js
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platform/worker_render";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import {platform} from "angular2/core";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								platform([WORKER_RENDER_PLATFORM])
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 19:37:42 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								.application([WORKER_RENDER_APPLICATION, {provide: WORKER_SCRIPT, useValue: "loader.js"};
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```JavaScript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// loader.js
							 
						 
					
						
							
								
									
										
										
										
											2015-09-11 16:00:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0 .16.js", "angular2/web_worker/worker.js");
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								System.import("app");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```TypeScript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// app.ts
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {Component, View, platform} from "angular2/core";
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 00:47:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {WORKER_APP_PLATFORM, WORKER_APP_APPLICATION} from "angular2/platform/worker_app";
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								@Component ({ 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  selector: "hello-world"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								})
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@View ({ 
						 
					
						
							
								
									
										
										
										
											2016-01-25 19:43:45 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  template: "< h1 > Hello {{name}}< / h1 > "
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								})
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								export class HelloWorld {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  name: string = "Jane";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								platform([WORKER_APP_PLATFORM])
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 00:47:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								.application([WORKER_APP_APPLICATION])
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								.then((ref) => ref.bootstrap(RootComponent));
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								There's a few important things to note here:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  The UI loads angular from the file `angular2/web_worker/ui.js`  and the Worker loads angular from 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`angular2/web_worker/worker.js` . These bundles are created specifically for using WebWorkers and should be used 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								instead of the normal angular2.js file. Both files contain subsets of the angular2 codebase that is designed to
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								run specifically on the UI or Worker. Additionally, they contain the core messaging infrastructure used to
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								communicate between the Worker and the UI. This messaging code is not in the standard angular2.js file.
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  We pass `loader.js`  to our application injector using the WORKER_SCRIPT symbol. This tells angular that our WebWorkers's init script is located at `loader.js` . 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								You can think of `loader.js`  as the index.html file for the WebWorker.
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 22:30:42 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Since WebWorkers share no memory with the UI we need to reload the Angular dependencies before
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bootstrapping our application. We do this with `importScripts` . Additionally, we need to do this in a different
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								file than `app.ts`  because our module loader (System.js in this example) has not been loaded yet, and `app.ts` 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								will be compiled with a `System.define`  call at the top.
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 22:30:42 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  The HelloWorld Component looks exactly like a normal Angular HelloWorld Component! The goal of WebWorker 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								support was to allow as much of Angular to live in the worker as possible.
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 22:30:42 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								As such, *most*  Angular components can be bootstrapped in a WebWorker with minimal to no changes required.
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								For reference, here's the same HelloWorld example in Dart.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```HTML
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< html >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < body > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < script  type = "application/dart"  src = "index.dart" > < / script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < script  src = "packages/browser.dart.js" > < / script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < / body > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / html >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```Dart
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// index.dart
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import "angular2/core.dart";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import "angular2/platform/worker_render.dart";
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								main() {
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  platform([WORKER_RENDER_PLATFORM])
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .asyncApplication(initIsolate("my_worker.dart"));
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```Dart
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// background_index.dart
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import "angular2/core.dart";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import "angular2/platform/worker_app.dart";
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								import "package:angular2/src/core/reflection/reflection.dart";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import "package:angular2/src/core/reflection/reflection_capabilities.dart";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@Component ( 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  selector: "hello-world"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@View ( 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  template: "< h1 > Hello {{name}}< / h1 > "
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								class HelloWorld {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  String name = "Jane";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								main(List< String >  args, SendPort replyTo) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  reflector.reflectionCapabilities = new ReflectionCapabilities();
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 19:37:42 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  platform([WORKER_APP_PLATFORM, {provide: RENDER_SEND_PORT, useValue: replyTo}])
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 00:47:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  .application([WORKER_APP_APPLICATION])
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .bootstrap(RootComponent);
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This code is nearly the same as the TypeScript version with just a couple key differences:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  We don't have a `loader.js`  file. Dart applications don't need this file because you don't need a module loader. 
						 
					
						
							
								
									
										
										
										
											2015-12-13 00:47:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  We provide a `SendPort`  through DI using the token `RENDER_SEND_PORT` .  Dart applications use the Isolate API, which communicates via 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Dart's Port abstraction. When you call `setupIsolate`  from the UI thread, angular starts a new Isolate to run
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								your application logic. When Dart starts a new Isolate it passes a `SendPort`  to that Isolate so that it
							 
						 
					
						
							
								
									
										
										
										
											2019-10-07 22:53:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								can communicate with the Isolate that spawned it. You need to provide this `SendPort`  through DI
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								so that Angular can communicate with the UI.
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  You need to set up `ReflectionCapabilities`  on both the UI and Worker. Just like writing non-concurrent 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Angular2 Dart applications you need to set up the reflector. You should not use Reflection in production,
							 
						 
					
						
							
								
									
										
										
										
											2017-01-26 22:30:42 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								but should use the Angular transformer to remove it in your final JS code. Note there's currently a bug
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								with running the transformer on your UI code (#3971 ). You can (and should) pass the file where you call
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 00:47:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								`bootstrap`  as an entry point to the transformer, but you should not pass your UI index file 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								to the transformer until that bug is fixed.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Writing WebWorker Compatible Components
  
						 
					
						
							
								
									
										
										
										
											2017-01-26 22:30:42 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								You can do almost everything in a WebWorker component that you can do in a typical Angular Component.
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The main exception is that there is **no**  DOM access from a WebWorker component. In Dart this means you can't
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import anything from `dart:html`  and in JavaScript it means you can't use `document`  or `window` . Instead you
							 
						 
					
						
							
								
									
										
										
										
											2019-10-07 22:53:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								should use data bindings and if needed you can inject `Renderer2`  along with your component's `ElementRef` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								directly into your component and use methods such as `setProperty` , `setAttribute` ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`addClass` , `setStyle` , and `setValue` . Note that you **cannot**  call 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								`getNativeElementSync` . Doing so will always return `null`  when running in a WebWorker. 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								If you need DOM access see [Running Code on the UI ](#running-code-on-the-ui ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## WebWorker Design Overview
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								When running your application in a WebWorker, the majority of the angular core along with your application logic
							 
						 
					
						
							
								
									
										
										
										
											2019-10-07 22:53:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								runs on the worker. The two main components that run on the UI are the `Renderer2`  and the `RenderCompiler` . When
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								running angular in a WebWorker the bindings for these two components are replaced by the `WebWorkerRenderer`  and
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								the `WebWorkerRenderCompiler` . When these components are used at runtime, they pass messages through the
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								[MessageBroker ](#messagebroker ) instructing the UI to run the actual method and return the result. The
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[MessageBroker ](#messagebroker ) abstraction allows either side of the WebWorker boundary to schedule code to run
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								on the opposite side and receive the result. You can use the [MessageBroker ](#messagebroker )
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Additionally, the [MessageBroker ](#messagebroker ) sits on top of the [MessageBus ](#messagebus ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								MessageBus is a low level abstraction that provides a language agnostic API for communicating with angular components across any runtime boundary such as `WebWorker <--> UI`  communication, `UI <--> Server`  communication,
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								or `Window <--> Window`  communication.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								See the diagram below for a high level overview of how this code is structured:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Running Code on the UI
  
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								If your application needs to run code on the UI, there are a few options. The easiest way is to use a
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								CustomElement in your view. You can then register this custom element from your html file and run code in response
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								to the element's lifecycle hooks. Note, Custom Elements are still experimental. See
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								[MDN ](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Custom_Elements ) for the latest details on how
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								to use them.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If you require more robust communication between the WebWorker and the UI you can use the [MessageBroker ](#using-the-messagebroker-in-your-application ) or
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[MessageBus ](#using-the-messagebus-in-your-application ) directly.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## MessageBus
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The MessageBus is a low level abstraction that provides a language agnostic API for communicating with angular components across any runtime boundary. It supports multiplex communication through the use of a channel
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								abstraction.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Angular currently includes two stable MessageBus implementations, which are used by default when you run your
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								application inside a WebWorker.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1.  The `PostMessageBus`  is used by JavaScript applications to communicate between a WebWorker and the UI. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								2.  The `IsolateMessageBus`  is used by Dart applications to communicate between a background Isolate and the UI. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Angular also includes three experimental MessageBus implementations:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1.  The `WebSocketMessageBus`  is a Dart MessageBus that lives on the UI and communicates with an angular 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								application running on a server. It's intended to be used with either the `SingleClientServerMessageBus`  or the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`MultiClientServerMessageBus` . 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								2.  The `SingleClientServerMessageBus`  is a Dart MessageBus that lives on a Dart Server. It allows an angular 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								application to run on a server and communicate with a single browser that's running the `WebSocketMessageBus` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								3.  The `MultiClientServerMessageBus`  is like the `SingleClientServerMessageBus`  except it allows an arbitrary 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								number of clients to connect to the server. It keeps all connected browsers in sync and if an event fires in
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								any connected browser it propagates the result to all connected clients. This can be especially useful as a
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								debugging tool, by allowing you to connect multiple browsers / devices to the same angular application,
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								change the state of that application, and ensure that all the clients render the view correctly. Using these tools
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								can make it easy to catch tricky browser compatibility issues.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Using the MessageBus in Your Application
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								**Note**: If you want to pass custom messages between the UI and WebWorker, it's recommended you use the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[MessageBroker ](#using-the-messagebroker-in-your-application ). However, if you want to control the messaging
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								protocol yourself you can use the MessageBus directly.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								You can obtain the MessageBus on both the render and worker thread through DI.
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								To use the MessageBus you need to initialize a new channel on both the UI and WebWorker.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								In TypeScript that would look like this:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```TypeScript
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 17:39:48 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// public_api.ts, which is running on the UI.
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT, MessageBus} from "angular2/platform/worker_render";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import {platform} from "angular2/core";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								let appRef = platform([WORKER_RENDER_PLATFORM])
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 19:37:42 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								.application([WORKER_RENDER_APPLICATION, {provide: WORKER_SCRIPT, useValue: "loader.js"};
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								let bus = appRef.injector.get(MessageBus);
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								bus.initChannel("My Custom Channel");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```TypeScript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// background_index.ts, which is running on the WebWorker
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {MessageBus} from 'angular2/platform/worker_app';
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								@Component ({...}) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@View ({...}) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								export class MyComponent {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  constructor (bus: MessageBus) {
							 
						 
					
						
							
								
									
										
										
										
											2015-09-10 10:39:28 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    bus.initChannel("My Custom Channel");
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Once the channel has been initialized either side can use the `from`  and `to`  methods on the MessageBus to send
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								and receive messages. Both methods return EventEmitter. Expanding on the example from earlier:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```TypeScript
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 17:39:48 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// public_api.ts, which is running on the UI.
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT, MessageBus} from "angular2/platform/worker_render";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import {platform} from "angular2/core";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								let appRef = platform([WORKER_RENDER_PLATFORM])
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 19:37:42 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								.application([WORKER_RENDER_APPLICATION, {provide: WORKER_SCRIPT, useValue: "loader.js"};
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								let bus = appRef.injector.get(MessageBus);
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								bus.initChannel("My Custom Channel");
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bus.to("My Custom Channel").emit("Hello from the UI");
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```TypeScript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// background_index.ts, which is running on the WebWorker
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {Component, View} from 'angular2/core';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import {MessageBus} from 'angular2/platform/worker_app';
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								@Component ({...}) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@View ({...}) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								export class MyComponent {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  constructor (bus: MessageBus) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bus.initChannel("My Custom Channel");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bus.from("My Custom Channel").observer((message) => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      console.log(message); // will print "hello from the UI"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This example is nearly identical in Dart, and is included below for reference:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```Dart
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// index.dart, which is running on the UI.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import 'package:angular2/web_workers/ui.dart';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								main() {
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  import "angular2/core.dart";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  import "angular2/platform/worker_render.dart";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  platform([WORKER_RENDER_PLATFORM])
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .asyncApplication(initIsolate("my_worker.dart")).then((ref) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var bus = ref.injector.get(MessageBus);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bus.initChannel("My Custom Channel");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bus.to("My Custom Channel").add("hello from the UI");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  });
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```Dart
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// background_index.dart, which is running on the WebWorker
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import 'package:angular2/platform/worker_app.dart';
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								@Component (...) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@View (...) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								class MyComponent {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  MyComponent (MessageBus bus) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bus.initChannel("My Custom Channel");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bus.from("My Custom Channel").listen((message) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      print(message); // will print "hello from the UI"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The only substantial difference between these APIs in Dart and TypeScript is the different APIs for the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`EventEmitter` . 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								**Note:** Because the messages passed through the MessageBus cross a WebWorker boundary, they must be serializable.
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								If you use the MessageBus directly, you are responsible for serializing your messages.
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								In JavaScript / TypeScript this means they must be serializable via JavaScript's
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								[structured cloning algorithim ](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### MessageBus and Zones
  
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The MessageBus API includes support for [zones ](http://www.github.com/angular/zone.js ).
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								A MessageBus can be attached to a specific zone  (by calling `attachToZone` ). Then specific channels can be
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								specified to run in the zone when they are initialized.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If a channel is running in the zone, that means that any events emitted from that channel will be executed within
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								the given zone. For example, by default angular runs the EventDispatch channel inside the angular zone. That means
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								when an event is fired from the DOM and received on the WebWorker the event handler automatically runs inside the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								angular zone. This is desired because after the event handler exits we want to exit the zone so that we trigger
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								change detection. Generally, you want your channels to run inside the zone unless you have a good reason for why
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								they need to run outside the zone.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Implementing and Using a Custom MessageBus
  
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								**Note:** Implementing and using a Custom MessageBus is experimental and the APIs may change.
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If you want to drive your application from something other than a WebWorker you can implement a custom message
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bus. Implementing a custom message bus just means creating a class that fulfills the API specified by the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								abstract MessageBus class.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If you're implementing your MessageBus in Dart you can extend the `GenericMessageBus`  class included in angular.
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if you do this, you don't need to implement zone or channel support yourself. You only need to implement a
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`MessageBusSink`  that extends `GenericMessageBusSink`  and a `MessageBusSource`  that extends 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								`GenericMessageBusSource` . The `MessageBusSink`  must override the `sendMessages`  method. This method is 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								given a list of serialized messages that it is required to send through the sink.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-07 22:53:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Once you've implemented your custom MessageBus in either TypeScript, you must provide it through DI
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								during bootstrap like so:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								In TypeScript:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```TypeScript
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 17:39:48 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// public_api.ts, running on the UI side
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 19:37:42 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {platform, APP_INITIALIZER, Injector} from 'angular2/core';
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    WORKER_RENDER_PLATFORM,
							 
						 
					
						
							
								
									
										
										
										
											2015-12-30 19:08:06 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    WORKER_RENDER_APPLICATION_COMMON,
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    initializeGenericWorkerRenderer,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    MessageBus
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} from 'angular2/platform/worker_render';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								var bus = new MyAwesomeMessageBus();
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								platform([WORKER_RENDER_PLATFORM])
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 19:37:42 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								.application([WORKER_RENDER_APPLICATION_COMMON, {provide: MessageBus, useValue: bus},
							 
						 
					
						
							
								
									
										
										
										
											2019-10-07 22:53:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  { provide: APP_INITIALIZER,
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    deps: [Injector],
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    multi: true
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 19:37:42 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								]);
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```TypeScript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// background_index.ts, running on the application side
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {WORKER_APP_PLATFORM, genericWorkerAppProviders} from "angular2/platform/worker_app";
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 19:37:42 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {NgZone, platform} from "angular/core";
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								import {MyApp} from './app';
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 00:47:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Do initialization work here to set up the app thread and MessageBus;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Once you have a working MessageBus you should bootstrap your app.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								platform([WORKER_APP_PLATFORM_PROVIDERS])
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 19:37:42 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								.application([WORKER_APP_APPLICATION_COMMON, {provide: MessageBus, useValue: bus},
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{provide: APP_INITIALIZER, useFactory: (zone, bus) => () => initAppThread(zone, bus), multi: true, deps: [NgZone, MessageBus]}])
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 00:47:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								.bootstrap(MyApp);
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 00:47:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function initAppThread(zone: NgZone, bus: MyAwesomeMessageBus): void{
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  /**
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 00:47:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								   *  Here you can do any initilization work that requires the app providers to be initialized.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								   *  At a minimum, you must attach your bus to the zone and setup a DOM adapter.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								   *  Depending on your environment you may choose to do more work here.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  */
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2015-12-30 19:08:06 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Notice how we use the `WORKER_RENDER_APPLICTION_COMMON`  providers instead of the `WORKER_RENDER_APPLICATION`  providers on the render thread.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is because the `WORKER_RENDER_APPLICATION`  providers include an application initializer that starts a new WebWorker/Isolate.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The `WORKER_RENDER_APPLICATION_COMMON`  providers make no assumption about where your application code lives.
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								However, we now need to provide our own app initializer. At the very least this initializer needs to call `initializeGenericWorkerRenderer` .
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## MessageBroker
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The MessageBroker is a higher level messaging abstraction that sits on top of the MessageBus. It is used when you
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								want to execute code on the other side of a runtime boundary and may want to receive the result.
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								There are two types of MessageBrokers:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1.  The `ServiceMessageBroker`  is used by the side that actually performs 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								an operation and may return a result;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								2.  The `ClientMessageBroker`  is used by the side that requests that 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								an operation be performed and may want to receive the result.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Using the MessageBroker In Your Application
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								To use MessageBrokers in your application you must initialize both a `ClientMessageBroker`  and a
							 
						 
					
						
							
								
									
										
										
										
											2015-09-10 10:39:28 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								`ServiceMessageBroker`  on the same channel. You can then register methods with the `ServiceMessageBroker`  and 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								instruct the `ClientMessageBroker`  to run those methods. Below is a lightweight example of using
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								MessageBrokers in an application. For a more complete example, check out the `WebWorkerRenderer`  and
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`MessageBasedRenderer`  inside the Angular WebWorker code. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Using the MessageBroker in TypeScript
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```TypeScript
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 17:39:48 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// public_api.ts, which is running on the UI with a method that we want to expose to a WebWorker
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT, ServiceMessageBrokerFactory} from "angular2/platform/worker_render";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import {platform} from "angular2/core";
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								let appRef = platform([WORKER_RENDER_PLATFORM])
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 19:37:42 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								.application([WORKER_RENDER_APPLICATION, {provide: WORKER_SCRIPT, useValue: "loader.js"};
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								let injector = instance.injector;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var broker = injector.get(ServiceMessageBrokerFactory).createMessageBroker("My Broker Channel");
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// assume we have some function doCoolThings that takes a string argument and returns a Promise< string > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								broker.registerMethod("awesomeMethod", [PRIMITIVE], (arg1: string) => doCoolThing(arg1), PRIMITIVE);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```TypeScript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// background.ts, which is running on a WebWorker and wants to execute a method on the UI
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import {Component, View} from 'angular2/core';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import {ClientMessageBrokerFactory, PRIMITIVE, UiArguments, FnArgs} from 'angular2/platform/worker_app';
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@Component (...) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@View (...) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								export class MyComponent {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  constructor(brokerFactory: ClientMessageBrokerFactory) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var broker = brokerFactory.createMessageBroker("My Broker Channel");
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    var arguments = [new FnArg(value, PRIMITIVE)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var methodInfo = new UiArguments("awesomeMethod", arguments);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    broker.runOnService(methodInfo, PRIMTIVE).then((result: string) => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      // result will be equal to the return value of doCoolThing(value) that ran on the UI.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Using the MessageBroker in Dart
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```Dart
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// index.dart, which is running on the UI with a method that we want to expose to a WebWorker
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import "angular2/core.dart";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import "angular2/platform/worker_render.dart";
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								main() {
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  platform([WORKER_RENDER_PLATFORM])
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .asyncApplication(initIsolate("my_worker.dart")).then((ref) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var broker = ref.injector.get(ServiceMessageBrokerFactory).createMessageBroker("My Broker Channel");
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // assume we have some function doCoolThings that takes a String argument and returns a Future< String > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    broker.registerMethod("awesomeMethod", [PRIMITIVE], (String arg1) => doCoolThing(arg1), PRIMITIVE);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  });
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```Dart
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// background.dart, which is running on a WebWorker and wants to execute a method on the UI
							 
						 
					
						
							
								
									
										
											 
										
											
												refactor(WebWorker): Use the new generic bootstrap.
BREAKING CHANGE:
You can no longer bootstrap a WebWorker or Isolate using `bootstrap` or `bootstrapWebWorker`. Instead you have to do the following:
In TypeScript:
```TypeScript
// index.js
import {WORKER_RENDER_PLATFORM, WORKER_RENDER_APPLICATION, WORKER_SCRIPT} from "angular2/platforms/worker_render";
import {platform} from "angular2/platform";
platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"});
```
```JavaScript
// loader.js
importScripts("https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js", "https://jspm.io/system@0.16.js", "angular2/web_worker/worker.js");
System.import("app");
```
```TypeScript
// app.ts
import {Component, View} from "angular2/core";
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platforms/worker_app";
import {platform} from "angular2/platform";
@Component({
  selector: "hello-world"
})
@View({
  template: "<h1>Hello {{name}}</h1>
})
export class HelloWorld {
  name: string = "Jane";
}
platform([WORKER_APP_PLATFORM])
.asyncApplication(setupWebWorker, optionalProviders?)
.then((ref) => ref.bootstrap(RootComponent));
```
In Dart:
```Dart
// index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_render.dart";
main() {
  platform([WORKER_RENDER_PLATFORM])
  .asyncApplication(initIsolate("my_worker.dart"));
}
```
```Dart
// background_index.dart
import "angular2/platform.dart";
import "angular2/platforms/worker_app.dart";
import "package:angular2/src/core/reflection/reflection.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
@Component(
  selector: "hello-world"
)
@View(
  template: "<h1>Hello {{name}}</h1>"
)
class HelloWorld {
  String name = "Jane";
}
main(List<String> args, SendPort replyTo) {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  platform([WORKER_APP_PLATFORM])
    .asyncApplication(setupIsolate(replyTo))
      .then((ref) => ref.bootstrap(RootComponent));
}
```
You should no longer import from the `angular2/web_worker/worker` and `angular2/web_worker/ui` paths. Instead you can now import directly from core, directives, etc..
The WebWorkerApplication class has been removed. If you want to use ServiceMessageBroker or ClientMessageBroker on the render thread, you must inject their factories via DI.
If you need to use the MessageBus on the render thread you must also obtain it through DI.
closes #3277
closes #5473
Closes #5519
											 
										 
										
											2015-12-02 20:25:24 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import 'package:angular2/core.dart';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import 'package:angular2/platform/worker_app.dart';
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@Component (...) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@View (...) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								class MyComponent {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  MyComponent(ClientMessageBrokerFactory brokerFactory) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var broker = brokerFactory.createMessageBroker("My Broker Channel");
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    var arguments = [new FnArg(value, PRIMITIVE)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var methodInfo = new UiArguments("awesomeMethod", arguments);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    broker.runOnService(methodInfo, PRIMTIVE).then((String result) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      // result will be equal to the return value of doCoolThing(value) that ran on the UI.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Both the client and the service create new MessageBrokers and attach them to the same channel.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The service then calls `registerMethod`  to register the method that it wants to listen to. Register method takes
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								four arguments. The first is the name of the method, the second is the Types of that method's parameters, the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								third is the method itself, and the fourth (which is optional) is the return Type of that method.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The MessageBroker handles serializing / deserializing your parameters and return types using angular's serializer.
							 
						 
					
						
							
								
									
										
										
										
											2019-10-07 22:53:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								However, at the moment the serializer only knows how to serialize angular classes like those used by `Renderer2` .
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								If you're passing anything other than those types around in your application you can handle serialization yourself
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								and then use the `PRIMITIVE`  type to tell the MessageBroker to avoid serializing your data.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-30 08:44:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The last thing that happens is that the client calls `runOnService`  with the name of the method it wants to run,
							 
						 
					
						
							
								
									
										
										
										
											2015-09-09 11:24:59 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								a list of that method's arguments and their types, and (optionally) the expected return type.