@@ -9,28 +9,8 @@ import {StringMapWrapper} from 'angular2/src/facade/collection';
99import { Injectable } from "angular2/src/core/di" ;
1010import { 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
3515export 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 */
142145class _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