X Tutup
Skip to content

Commit eda6a5d

Browse files
committed
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 angular#6184 Closes angular#6378
1 parent c1c54ed commit eda6a5d

File tree

11 files changed

+37
-26
lines changed

11 files changed

+37
-26
lines changed

modules/angular2/docs/web_workers/web_workers.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,14 @@ In TypeScript:
371371
import {platform, Provider, APP_INITIALIZER, Injector} from 'angular2/core';
372372
import {
373373
WORKER_RENDER_PLATFORM,
374-
WORKER_RENDER_APP_COMMON,
374+
WORKER_RENDER_APPLICATION_COMMON,
375375
initializeGenericWorkerRenderer,
376376
MessageBus
377377
} from 'angular2/platform/worker_render';
378378
379379
var bus = new MyAwesomeMessageBus();
380380
platform([WORKER_RENDER_PLATFORM])
381-
.application([WORKER_RENDER_APP_COMMON, new Provider(MessageBus, {useValue: bus}),
381+
.application([WORKER_RENDER_APPLICATION_COMMON, new Provider(MessageBus, {useValue: bus}),
382382
new Provider(APP_INITIALIZER, {
383383
useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),
384384
deps: [Injector],
@@ -419,7 +419,7 @@ import 'package:angular2/platform/worker_render.dart';
419419
main() {
420420
var bus = new MyAwesomeMessageBus();
421421
platform([WORKER_RENDER_PLATFORM])
422-
.application([WORKER_RENDER_APP_COMMON, new Provider(MessageBus, useValue: bus),
422+
.application([WORKER_RENDER_APPLICATION_COMMON, new Provider(MessageBus, useValue: bus),
423423
new Provider(APP_INITIALIZER,
424424
useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),
425425
deps: [Injector],
@@ -456,9 +456,9 @@ void initAppThread(NgZone zone) {
456456
*/
457457
}
458458
```
459-
Notice how we use the `WORKER_RENDER_APP_COMMON` providers instead of the `WORKER_RENDER_APP` providers on the render thread.
460-
This is because the `WORKER_RENDER_APP` providers include an application initializer that starts a new WebWorker/Isolate.
461-
The `WORKER_RENDER_APP_COMMON` providers make no assumption about where your application code lives.
459+
Notice how we use the `WORKER_RENDER_APPLICTION_COMMON` providers instead of the `WORKER_RENDER_APPLICATION` providers on the render thread.
460+
This is because the `WORKER_RENDER_APPLICATION` providers include an application initializer that starts a new WebWorker/Isolate.
461+
The `WORKER_RENDER_APPLICATION_COMMON` providers make no assumption about where your application code lives.
462462
However, we now need to provide our own app initializer. At the very least this initializer needs to call `initializeGenericWorkerRenderer`.
463463

464464
## MessageBroker

modules/angular2/platform/worker_render.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ export 'package:angular2/src/platform/worker_render_common.dart'
44
show
55
WORKER_SCRIPT,
66
WORKER_RENDER_PLATFORM,
7-
WORKER_RENDER_APP_COMMON,
7+
WORKER_RENDER_APPLICATION_COMMON,
88
initializeGenericWorkerRenderer;
99

1010
export 'package:angular2/src/platform/worker_render.dart'
11-
show WORKER_RENDER_APP, initIsolate, WebWorkerInstance;
11+
show WORKER_RENDER_APPLICATION, initIsolate, WebWorkerInstance;
1212

1313
export '../src/web_workers/shared/client_message_broker.dart'
1414
show ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments;
@@ -18,3 +18,7 @@ export '../src/web_workers/shared/service_message_broker.dart'
1818

1919
export '../src/web_workers/shared/serializer.dart' show PRIMITIVE;
2020
export '../src/web_workers/shared/message_bus.dart';
21+
22+
import 'package:angular2/src/platform/worker_render_common.dart';
23+
24+
const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION_COMMON;

modules/angular2/platform/worker_render.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ export {
22
WORKER_SCRIPT,
33
WORKER_RENDER_PLATFORM,
44
initializeGenericWorkerRenderer,
5-
WORKER_RENDER_APP_COMMON
5+
WORKER_RENDER_APPLICATION_COMMON
66
} from 'angular2/src/platform/worker_render_common';
7-
export * from 'angular2/src/platform/worker_render';
7+
export {WORKER_RENDER_APPLICATION, WebWorkerInstance} from 'angular2/src/platform/worker_render';
88
export {
99
ClientMessageBroker,
1010
ClientMessageBrokerFactory,
@@ -18,3 +18,9 @@ export {
1818
} from '../src/web_workers/shared/service_message_broker';
1919
export {PRIMITIVE} from '../src/web_workers/shared/serializer';
2020
export * from '../src/web_workers/shared/message_bus';
21+
import {WORKER_RENDER_APPLICATION} from 'angular2/src/platform/worker_render';
22+
23+
/**
24+
* @deprecated Use WORKER_RENDER_APPLICATION
25+
*/
26+
export const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION;

modules/angular2/src/platform/worker_render.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ library angular2.src.platform.worker_render;
22

33
import 'package:angular2/src/platform/worker_render_common.dart'
44
show
5-
WORKER_RENDER_APP_COMMON,
5+
WORKER_RENDER_APPLICATION_COMMON,
66
WORKER_RENDER_MESSAGING_PROVIDERS,
77
WORKER_SCRIPT,
88
initializeGenericWorkerRenderer;
@@ -14,14 +14,14 @@ import 'package:angular2/src/core/zone/ng_zone.dart';
1414
import 'dart:isolate';
1515
import 'dart:async';
1616

17-
const WORKER_RENDER_APP = WORKER_RENDER_APP_COMMON;
17+
const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION_COMMON;
1818

1919
initIsolate(String scriptUri) {
2020
return (NgZone zone) async {
2121
var instance = await spawnIsolate(Uri.parse(scriptUri));
2222

2323
return [
24-
WORKER_RENDER_APP_COMMON,
24+
WORKER_RENDER_APPLICATION_COMMON,
2525
new Provider(WebWorkerInstance, useValue: instance),
2626
new Provider(APP_INITIALIZER,
2727
useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),

modules/angular2/src/platform/worker_render.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {Injector, Injectable, Provider} from 'angular2/src/core/di';
99
import {MessageBasedRenderer} from 'angular2/src/web_workers/ui/renderer';
1010
import {MessageBasedXHRImpl} from 'angular2/src/web_workers/ui/xhr_impl';
1111
import {
12-
WORKER_RENDER_APP_COMMON,
12+
WORKER_RENDER_APPLICATION_COMMON,
1313
WORKER_RENDER_MESSAGING_PROVIDERS,
1414
WORKER_SCRIPT,
1515
initializeGenericWorkerRenderer
@@ -36,8 +36,8 @@ export class WebWorkerInstance {
3636
/**
3737
* An array of providers that should be passed into `application()` when initializing a new Worker.
3838
*/
39-
export const WORKER_RENDER_APP: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
40-
WORKER_RENDER_APP_COMMON,
39+
export const WORKER_RENDER_APPLICATION: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
40+
WORKER_RENDER_APPLICATION_COMMON,
4141
WebWorkerInstance,
4242
new Provider(APP_INITIALIZER,
4343
{

modules/angular2/src/platform/worker_render_common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const WORKER_RENDER_PLATFORM: Array<any /*Type | Provider | any[]*/> = CO
5959
new Provider(PLATFORM_INITIALIZER, {useValue: initWebWorkerRenderPlatform, multi: true})
6060
]);
6161

62-
export const WORKER_RENDER_APP_COMMON: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
62+
export const WORKER_RENDER_APPLICATION_COMMON: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
6363
APPLICATION_COMMON_PROVIDERS,
6464
WORKER_RENDER_MESSAGING_PROVIDERS,
6565
new Provider(ExceptionHandler, {useFactory: _exceptionHandler, deps: []}),
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {platform, Provider} from 'angular2/core';
22
import {
3-
WORKER_RENDER_APP,
3+
WORKER_RENDER_APPLICATION,
44
WORKER_RENDER_PLATFORM,
55
WORKER_SCRIPT
66
} from 'angular2/platform/worker_render';
77

88
platform([WORKER_RENDER_PLATFORM])
9-
.application([WORKER_RENDER_APP, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
9+
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {platform, Provider} from 'angular2/core';
22
import {
3-
WORKER_RENDER_APP,
3+
WORKER_RENDER_APPLICATION,
44
WORKER_RENDER_PLATFORM,
55
WORKER_SCRIPT
66
} from 'angular2/platform/worker_render';
77

88
platform([WORKER_RENDER_PLATFORM])
9-
.application([WORKER_RENDER_APP, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
9+
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);

modules/playground/src/web_workers/message_broker/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {platform, Provider} from 'angular2/core';
22
import {
3-
WORKER_RENDER_APP,
3+
WORKER_RENDER_APPLICATION,
44
WORKER_RENDER_PLATFORM,
55
WORKER_SCRIPT,
66
UiArguments,
@@ -13,7 +13,8 @@ const ECHO_CHANNEL = "ECHO";
1313

1414
let ref =
1515
platform([WORKER_RENDER_PLATFORM])
16-
.application([WORKER_RENDER_APP, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
16+
.application(
17+
[WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
1718
let brokerFactory: ClientMessageBrokerFactory = ref.injector.get(ClientMessageBrokerFactory);
1819
var broker = brokerFactory.createMessageBroker(ECHO_CHANNEL, false);
1920

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {platform, Provider} from 'angular2/core';
22
import {
3-
WORKER_RENDER_APP,
3+
WORKER_RENDER_APPLICATION,
44
WORKER_RENDER_PLATFORM,
55
WORKER_SCRIPT
66
} from 'angular2/platform/worker_render';
77

88
platform([WORKER_RENDER_PLATFORM])
9-
.application([WORKER_RENDER_APP, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
9+
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);

0 commit comments

Comments
 (0)
X Tutup