nope/lib/communication/eventLayer.ts

15 lines
432 B
TypeScript
Raw Normal View History

2020-08-21 16:38:21 +00:00
import { EventEmitter } from "events";
2020-08-23 07:21:03 +00:00
import { CommunicationEvents, ICommunicationInterface } from "../dispatcher/nopeDispatcher";
2020-08-21 16:38:21 +00:00
2020-08-23 07:21:03 +00:00
/**
* Event Layer.
*/
2020-08-21 16:38:21 +00:00
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)
}
}