nope/lib/communication/eventLayer.ts
Martin Karkowski 52f4f5fc74 Adding Comments
2020-09-11 09:59:23 +02:00

20 lines
571 B
TypeScript

import { EventEmitter } from "events";
import { CommunicationEvents, ICommunicationInterface } from "../dispatcher/nopeDispatcher";
/**
* A Communication Layer for the Dispatchers.
* Here, only a Events are used.
*
* @export
* @class EventLayer
* @implements {ICommunicationInterface}
*/
export class EventLayer implements ICommunicationInterface {
protected _emitter = new EventEmitter();
on(event: CommunicationEvents, cb: (...args: any[]) => void) {
this._emitter.on(event, cb);
}
send(data: any): void {
this._emitter.emit('event', data)
}
}