12 lines
397 B
TypeScript
12 lines
397 B
TypeScript
import { EventEmitter } from "events";
|
|
import { CommunicationEvents, ICommunicationInterface } from "../callDispatcher";
|
|
|
|
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)
|
|
}
|
|
} |