Files
Angular-Docs-Cn/modules/angular2/src/web_workers/shared/message_bus.ts
T

45 lines
1.5 KiB
TypeScript
Raw Normal View History

2015-08-20 14:28:25 -07:00
import {EventEmitter} from 'angular2/src/core/facade/async';
import {BaseException} from 'angular2/src/core/facade/lang';
2015-08-27 10:39:39 -07:00
export {EventEmitter, Observable} from 'angular2/src/core/facade/async';
function _abstract() {
throw new BaseException("This method is abstract");
}
/**
* Message Bus is a low level API used to communicate between the UI and the background.
* Communication is based on a channel abstraction. Messages published in a
* given channel to one MessageBusSink are received on the same channel
* by the corresponding MessageBusSource.
*/
2015-08-21 12:21:29 -07:00
export /* abstract (with TS 1.6) */ class MessageBus implements MessageBusSource, MessageBusSink {
/**
* Returns an {@link EventEmitter} that emits every time a messsage
* is received on the given channel.
*/
2015-08-21 12:21:29 -07:00
from(channel: string): EventEmitter { throw _abstract(); }
/**
* Returns an {@link EventEmitter} for the given channel
* To publish methods to that channel just call next (or add in dart) on the returned emitter
*/
2015-08-21 12:21:29 -07:00
to(channel: string): EventEmitter { throw _abstract(); }
}
2015-07-10 16:09:18 -07:00
export interface MessageBusSource {
/**
* Returns an {@link EventEmitter} that emits every time a messsage
* is received on the given channel.
2015-07-10 16:09:18 -07:00
*/
from(channel: string): EventEmitter;
2015-07-10 16:09:18 -07:00
}
export interface MessageBusSink {
/**
* Returns an {@link EventEmitter} for the given channel
* To publish methods to that channel just call next (or add in dart) on the returned emitter
*/
to(channel: string): EventEmitter;
}