av/cmd/mjpeg-player/hlsjs/observer.js

16 lines
435 B
JavaScript
Raw Normal View History

2020-01-24 06:48:26 +03:00
import { EventEmitter } from 'eventemitter3';
/**
* Simple adapter sub-class of Nodejs-like EventEmitter.
*/
export class Observer extends EventEmitter {
/**
* We simply want to pass along the event-name itself
* in every call to a handler, which is the purpose of our `trigger` method
* extending the standard API.
*/
trigger (event: string, ...data: Array<any>): void {
this.emit(event, event, ...data);
}
}