X Tutup
Skip to content

Commit 01fe7f5

Browse files
jteplitzvsavkin
authored andcommitted
fix(WebWorker): Fix PostMessageBusSink and Source undefined error.
Closes #7156
1 parent 9aedef2 commit 01fe7f5

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

modules/angular2/src/web_workers/shared/post_message_bus.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,8 @@ import {StringMapWrapper} from 'angular2/src/facade/collection';
99
import {Injectable} from "angular2/src/core/di";
1010
import {NgZone} from 'angular2/src/core/zone/ng_zone';
1111

12-
/**
13-
* A TypeScript implementation of {@link MessageBus} for communicating via JavaScript's
14-
* postMessage API.
15-
*/
16-
@Injectable()
17-
export class PostMessageBus implements MessageBus {
18-
constructor(public sink: PostMessageBusSink, public source: PostMessageBusSource) {}
19-
20-
attachToZone(zone: NgZone): void {
21-
this.source.attachToZone(zone);
22-
this.sink.attachToZone(zone);
23-
}
24-
25-
initChannel(channel: string, runInZone: boolean = true): void {
26-
this.source.initChannel(channel, runInZone);
27-
this.sink.initChannel(channel, runInZone);
28-
}
29-
30-
from(channel: string): EventEmitter<any> { return this.source.from(channel); }
31-
32-
to(channel: string): EventEmitter<any> { return this.sink.to(channel); }
33-
}
12+
// TODO(jteplitz602) Replace this with the definition in lib.webworker.d.ts(#3492)
13+
export interface PostMessageTarget { postMessage: (message: any, transfer?:[ArrayBuffer]) => void; }
3414

3515
export class PostMessageBusSink implements MessageBusSink {
3616
private _zone: NgZone;
@@ -135,13 +115,33 @@ export class PostMessageBusSource implements MessageBusSource {
135115
}
136116
}
137117

118+
/**
119+
* A TypeScript implementation of {@link MessageBus} for communicating via JavaScript's
120+
* postMessage API.
121+
*/
122+
@Injectable()
123+
export class PostMessageBus implements MessageBus {
124+
constructor(public sink: PostMessageBusSink, public source: PostMessageBusSource) {}
125+
126+
attachToZone(zone: NgZone): void {
127+
this.source.attachToZone(zone);
128+
this.sink.attachToZone(zone);
129+
}
130+
131+
initChannel(channel: string, runInZone: boolean = true): void {
132+
this.source.initChannel(channel, runInZone);
133+
this.sink.initChannel(channel, runInZone);
134+
}
135+
136+
from(channel: string): EventEmitter<any> { return this.source.from(channel); }
137+
138+
to(channel: string): EventEmitter<any> { return this.sink.to(channel); }
139+
}
140+
138141
/**
139142
* Helper class that wraps a channel's {@link EventEmitter} and
140143
* keeps track of if it should run in the zone.
141144
*/
142145
class _Channel {
143146
constructor(public emitter: EventEmitter<any>, public runInZone: boolean) {}
144147
}
145-
146-
// TODO(jteplitz602) Replace this with the definition in lib.webworker.d.ts(#3492)
147-
export interface PostMessageTarget { postMessage: (message: any, transfer?:[ArrayBuffer]) => void; }

0 commit comments

Comments
 (0)
X Tutup