refactor(WebWorker): Rename WORKER_RENDER_APP to WORKER_RENDER_APPLICATION

BREAKING CHANGE

WORKER_RENDER_APP is now deprecated. Use WORKER_RENDER_APPLICATION instead
WORKER_RENDER_APP_COMMON has been replaced by WORKER_RENDER_APPLICATION_COMMON

closes #6184

Closes #6378
This commit is contained in:
Jason Teplitz 2015-12-30 19:08:06 -05:00
parent c1c54ed0f2
commit eda6a5d52a
11 changed files with 37 additions and 26 deletions

View File

@ -371,14 +371,14 @@ In TypeScript:
import {platform, Provider, APP_INITIALIZER, Injector} from 'angular2/core'; import {platform, Provider, APP_INITIALIZER, Injector} from 'angular2/core';
import { import {
WORKER_RENDER_PLATFORM, WORKER_RENDER_PLATFORM,
WORKER_RENDER_APP_COMMON, WORKER_RENDER_APPLICATION_COMMON,
initializeGenericWorkerRenderer, initializeGenericWorkerRenderer,
MessageBus MessageBus
} from 'angular2/platform/worker_render'; } from 'angular2/platform/worker_render';
var bus = new MyAwesomeMessageBus(); var bus = new MyAwesomeMessageBus();
platform([WORKER_RENDER_PLATFORM]) platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APP_COMMON, new Provider(MessageBus, {useValue: bus}), .application([WORKER_RENDER_APPLICATION_COMMON, new Provider(MessageBus, {useValue: bus}),
new Provider(APP_INITIALIZER, { new Provider(APP_INITIALIZER, {
useFactory: (injector) => () => initializeGenericWorkerRenderer(injector), useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),
deps: [Injector], deps: [Injector],
@ -419,7 +419,7 @@ import 'package:angular2/platform/worker_render.dart';
main() { main() {
var bus = new MyAwesomeMessageBus(); var bus = new MyAwesomeMessageBus();
platform([WORKER_RENDER_PLATFORM]) platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APP_COMMON, new Provider(MessageBus, useValue: bus), .application([WORKER_RENDER_APPLICATION_COMMON, new Provider(MessageBus, useValue: bus),
new Provider(APP_INITIALIZER, new Provider(APP_INITIALIZER,
useFactory: (injector) => () => initializeGenericWorkerRenderer(injector), useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),
deps: [Injector], deps: [Injector],
@ -456,9 +456,9 @@ void initAppThread(NgZone zone) {
*/ */
} }
``` ```
Notice how we use the `WORKER_RENDER_APP_COMMON` providers instead of the `WORKER_RENDER_APP` providers on the render thread. 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_APP` providers include an application initializer that starts a new WebWorker/Isolate. This is because the `WORKER_RENDER_APPLICATION` providers include an application initializer that starts a new WebWorker/Isolate.
The `WORKER_RENDER_APP_COMMON` providers make no assumption about where your application code lives. The `WORKER_RENDER_APPLICATION_COMMON` providers make no assumption about where your application code lives.
However, we now need to provide our own app initializer. At the very least this initializer needs to call `initializeGenericWorkerRenderer`. However, we now need to provide our own app initializer. At the very least this initializer needs to call `initializeGenericWorkerRenderer`.
## MessageBroker ## MessageBroker

View File

@ -4,11 +4,11 @@ export 'package:angular2/src/platform/worker_render_common.dart'
show show
WORKER_SCRIPT, WORKER_SCRIPT,
WORKER_RENDER_PLATFORM, WORKER_RENDER_PLATFORM,
WORKER_RENDER_APP_COMMON, WORKER_RENDER_APPLICATION_COMMON,
initializeGenericWorkerRenderer; initializeGenericWorkerRenderer;
export 'package:angular2/src/platform/worker_render.dart' export 'package:angular2/src/platform/worker_render.dart'
show WORKER_RENDER_APP, initIsolate, WebWorkerInstance; show WORKER_RENDER_APPLICATION, initIsolate, WebWorkerInstance;
export '../src/web_workers/shared/client_message_broker.dart' export '../src/web_workers/shared/client_message_broker.dart'
show ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments; show ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments;
@ -18,3 +18,7 @@ export '../src/web_workers/shared/service_message_broker.dart'
export '../src/web_workers/shared/serializer.dart' show PRIMITIVE; export '../src/web_workers/shared/serializer.dart' show PRIMITIVE;
export '../src/web_workers/shared/message_bus.dart'; export '../src/web_workers/shared/message_bus.dart';
import 'package:angular2/src/platform/worker_render_common.dart';
const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION_COMMON;

View File

@ -2,9 +2,9 @@ export {
WORKER_SCRIPT, WORKER_SCRIPT,
WORKER_RENDER_PLATFORM, WORKER_RENDER_PLATFORM,
initializeGenericWorkerRenderer, initializeGenericWorkerRenderer,
WORKER_RENDER_APP_COMMON WORKER_RENDER_APPLICATION_COMMON
} from 'angular2/src/platform/worker_render_common'; } from 'angular2/src/platform/worker_render_common';
export * from 'angular2/src/platform/worker_render'; export {WORKER_RENDER_APPLICATION, WebWorkerInstance} from 'angular2/src/platform/worker_render';
export { export {
ClientMessageBroker, ClientMessageBroker,
ClientMessageBrokerFactory, ClientMessageBrokerFactory,
@ -18,3 +18,9 @@ export {
} from '../src/web_workers/shared/service_message_broker'; } from '../src/web_workers/shared/service_message_broker';
export {PRIMITIVE} from '../src/web_workers/shared/serializer'; export {PRIMITIVE} from '../src/web_workers/shared/serializer';
export * from '../src/web_workers/shared/message_bus'; export * from '../src/web_workers/shared/message_bus';
import {WORKER_RENDER_APPLICATION} from 'angular2/src/platform/worker_render';
/**
* @deprecated Use WORKER_RENDER_APPLICATION
*/
export const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION;

View File

@ -2,7 +2,7 @@ library angular2.src.platform.worker_render;
import 'package:angular2/src/platform/worker_render_common.dart' import 'package:angular2/src/platform/worker_render_common.dart'
show show
WORKER_RENDER_APP_COMMON, WORKER_RENDER_APPLICATION_COMMON,
WORKER_RENDER_MESSAGING_PROVIDERS, WORKER_RENDER_MESSAGING_PROVIDERS,
WORKER_SCRIPT, WORKER_SCRIPT,
initializeGenericWorkerRenderer; initializeGenericWorkerRenderer;
@ -14,14 +14,14 @@ import 'package:angular2/src/core/zone/ng_zone.dart';
import 'dart:isolate'; import 'dart:isolate';
import 'dart:async'; import 'dart:async';
const WORKER_RENDER_APP = WORKER_RENDER_APP_COMMON; const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION_COMMON;
initIsolate(String scriptUri) { initIsolate(String scriptUri) {
return (NgZone zone) async { return (NgZone zone) async {
var instance = await spawnIsolate(Uri.parse(scriptUri)); var instance = await spawnIsolate(Uri.parse(scriptUri));
return [ return [
WORKER_RENDER_APP_COMMON, WORKER_RENDER_APPLICATION_COMMON,
new Provider(WebWorkerInstance, useValue: instance), new Provider(WebWorkerInstance, useValue: instance),
new Provider(APP_INITIALIZER, new Provider(APP_INITIALIZER,
useFactory: (injector) => () => initializeGenericWorkerRenderer(injector), useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),

View File

@ -9,7 +9,7 @@ import {Injector, Injectable, Provider} from 'angular2/src/core/di';
import {MessageBasedRenderer} from 'angular2/src/web_workers/ui/renderer'; import {MessageBasedRenderer} from 'angular2/src/web_workers/ui/renderer';
import {MessageBasedXHRImpl} from 'angular2/src/web_workers/ui/xhr_impl'; import {MessageBasedXHRImpl} from 'angular2/src/web_workers/ui/xhr_impl';
import { import {
WORKER_RENDER_APP_COMMON, WORKER_RENDER_APPLICATION_COMMON,
WORKER_RENDER_MESSAGING_PROVIDERS, WORKER_RENDER_MESSAGING_PROVIDERS,
WORKER_SCRIPT, WORKER_SCRIPT,
initializeGenericWorkerRenderer initializeGenericWorkerRenderer
@ -36,8 +36,8 @@ export class WebWorkerInstance {
/** /**
* An array of providers that should be passed into `application()` when initializing a new Worker. * An array of providers that should be passed into `application()` when initializing a new Worker.
*/ */
export const WORKER_RENDER_APP: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([ export const WORKER_RENDER_APPLICATION: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
WORKER_RENDER_APP_COMMON, WORKER_RENDER_APPLICATION_COMMON,
WebWorkerInstance, WebWorkerInstance,
new Provider(APP_INITIALIZER, new Provider(APP_INITIALIZER,
{ {

View File

@ -59,7 +59,7 @@ export const WORKER_RENDER_PLATFORM: Array<any /*Type | Provider | any[]*/> = CO
new Provider(PLATFORM_INITIALIZER, {useValue: initWebWorkerRenderPlatform, multi: true}) new Provider(PLATFORM_INITIALIZER, {useValue: initWebWorkerRenderPlatform, multi: true})
]); ]);
export const WORKER_RENDER_APP_COMMON: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([ export const WORKER_RENDER_APPLICATION_COMMON: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
APPLICATION_COMMON_PROVIDERS, APPLICATION_COMMON_PROVIDERS,
WORKER_RENDER_MESSAGING_PROVIDERS, WORKER_RENDER_MESSAGING_PROVIDERS,
new Provider(ExceptionHandler, {useFactory: _exceptionHandler, deps: []}), new Provider(ExceptionHandler, {useFactory: _exceptionHandler, deps: []}),

View File

@ -1,9 +1,9 @@
import {platform, Provider} from 'angular2/core'; import {platform, Provider} from 'angular2/core';
import { import {
WORKER_RENDER_APP, WORKER_RENDER_APPLICATION,
WORKER_RENDER_PLATFORM, WORKER_RENDER_PLATFORM,
WORKER_SCRIPT WORKER_SCRIPT
} from 'angular2/platform/worker_render'; } from 'angular2/platform/worker_render';
platform([WORKER_RENDER_PLATFORM]) platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APP, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]); .application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);

View File

@ -1,9 +1,9 @@
import {platform, Provider} from 'angular2/core'; import {platform, Provider} from 'angular2/core';
import { import {
WORKER_RENDER_APP, WORKER_RENDER_APPLICATION,
WORKER_RENDER_PLATFORM, WORKER_RENDER_PLATFORM,
WORKER_SCRIPT WORKER_SCRIPT
} from 'angular2/platform/worker_render'; } from 'angular2/platform/worker_render';
platform([WORKER_RENDER_PLATFORM]) platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APP, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]); .application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);

View File

@ -1,6 +1,6 @@
import {platform, Provider} from 'angular2/core'; import {platform, Provider} from 'angular2/core';
import { import {
WORKER_RENDER_APP, WORKER_RENDER_APPLICATION,
WORKER_RENDER_PLATFORM, WORKER_RENDER_PLATFORM,
WORKER_SCRIPT, WORKER_SCRIPT,
UiArguments, UiArguments,
@ -13,7 +13,8 @@ const ECHO_CHANNEL = "ECHO";
let ref = let ref =
platform([WORKER_RENDER_PLATFORM]) platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APP, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]); .application(
[WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
let brokerFactory: ClientMessageBrokerFactory = ref.injector.get(ClientMessageBrokerFactory); let brokerFactory: ClientMessageBrokerFactory = ref.injector.get(ClientMessageBrokerFactory);
var broker = brokerFactory.createMessageBroker(ECHO_CHANNEL, false); var broker = brokerFactory.createMessageBroker(ECHO_CHANNEL, false);

View File

@ -1,9 +1,9 @@
import {platform, Provider} from 'angular2/core'; import {platform, Provider} from 'angular2/core';
import { import {
WORKER_RENDER_APP, WORKER_RENDER_APPLICATION,
WORKER_RENDER_PLATFORM, WORKER_RENDER_PLATFORM,
WORKER_SCRIPT WORKER_SCRIPT
} from 'angular2/platform/worker_render'; } from 'angular2/platform/worker_render';
platform([WORKER_RENDER_PLATFORM]) platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APP, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]); .application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);

View File

@ -12,7 +12,7 @@ main() {
var bus = new WebSocketMessageBus.fromWebSocket(webSocket); var bus = new WebSocketMessageBus.fromWebSocket(webSocket);
platform([WORKER_RENDER_PLATFORM]) platform([WORKER_RENDER_PLATFORM])
.application([WORKER_RENDER_APP_COMMON, new Provider(MessageBus, useValue: bus), .application([WORKER_RENDER_APPLICATION_COMMON, new Provider(MessageBus, useValue: bus),
new Provider(APP_INITIALIZER, new Provider(APP_INITIALIZER,
useFactory: (injector) => () => initializeGenericWorkerRenderer(injector), useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),
deps: [Injector], deps: [Injector],