From 01fe7f5fac7b768668f10aa725e6207379bff059 Mon Sep 17 00:00:00 2001 From: Jason Teplitz Date: Thu, 18 Feb 2016 11:17:31 -0800 Subject: [PATCH] fix(WebWorker): Fix PostMessageBusSink and Source undefined error. Closes #7156 --- .../web_workers/shared/post_message_bus.ts | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/modules/angular2/src/web_workers/shared/post_message_bus.ts b/modules/angular2/src/web_workers/shared/post_message_bus.ts index 9577ebe9be..7733a1dd98 100644 --- a/modules/angular2/src/web_workers/shared/post_message_bus.ts +++ b/modules/angular2/src/web_workers/shared/post_message_bus.ts @@ -9,28 +9,8 @@ import {StringMapWrapper} from 'angular2/src/facade/collection'; import {Injectable} from "angular2/src/core/di"; import {NgZone} from 'angular2/src/core/zone/ng_zone'; -/** - * A TypeScript implementation of {@link MessageBus} for communicating via JavaScript's - * postMessage API. - */ -@Injectable() -export class PostMessageBus implements MessageBus { - constructor(public sink: PostMessageBusSink, public source: PostMessageBusSource) {} - - attachToZone(zone: NgZone): void { - this.source.attachToZone(zone); - this.sink.attachToZone(zone); - } - - initChannel(channel: string, runInZone: boolean = true): void { - this.source.initChannel(channel, runInZone); - this.sink.initChannel(channel, runInZone); - } - - from(channel: string): EventEmitter { return this.source.from(channel); } - - to(channel: string): EventEmitter { return this.sink.to(channel); } -} +// TODO(jteplitz602) Replace this with the definition in lib.webworker.d.ts(#3492) +export interface PostMessageTarget { postMessage: (message: any, transfer?:[ArrayBuffer]) => void; } export class PostMessageBusSink implements MessageBusSink { private _zone: NgZone; @@ -135,6 +115,29 @@ export class PostMessageBusSource implements MessageBusSource { } } +/** + * A TypeScript implementation of {@link MessageBus} for communicating via JavaScript's + * postMessage API. + */ +@Injectable() +export class PostMessageBus implements MessageBus { + constructor(public sink: PostMessageBusSink, public source: PostMessageBusSource) {} + + attachToZone(zone: NgZone): void { + this.source.attachToZone(zone); + this.sink.attachToZone(zone); + } + + initChannel(channel: string, runInZone: boolean = true): void { + this.source.initChannel(channel, runInZone); + this.sink.initChannel(channel, runInZone); + } + + from(channel: string): EventEmitter { return this.source.from(channel); } + + to(channel: string): EventEmitter { return this.sink.to(channel); } +} + /** * Helper class that wraps a channel's {@link EventEmitter} and * keeps track of if it should run in the zone. @@ -142,6 +145,3 @@ export class PostMessageBusSource implements MessageBusSource { class _Channel { constructor(public emitter: EventEmitter, public runInZone: boolean) {} } - -// TODO(jteplitz602) Replace this with the definition in lib.webworker.d.ts(#3492) -export interface PostMessageTarget { postMessage: (message: any, transfer?:[ArrayBuffer]) => void; }