UNPKG

video-ad-sdk

Version:

VAST/VPAID SDK that allows video ads to be played on top of any player

58 lines (57 loc) 2.15 kB
/** * Event listener function */ export interface Listener { (...args: any[]): void; _?: this; } /** * Subset of node's [Emitter class](https://nodejs.org/api/events.html#events_class_eventemitter) * * @param logger Optional logger instance. Must comply to the [Console interface](https://developer.mozilla.org/es/docs/Web/API/Console). */ export declare class Emitter { logger: Console; events: Record<string, Listener[]>; constructor(logger?: Console); /** * Adds the listener function to the end of the listeners array for the event named eventName. * * @param eventName The name of the event. * @param listener Listener fn that handles the evt. * @returns The Emitter instance. */ on(eventName: string, listener: Listener): this; /** * Removes the specified listener from the listener array for the event named eventName. * * @param eventName The name of the event. * @param listener Listener fn that handles the evt. * @returns The Emitter instance. */ removeListener(eventName: string, listener: Listener): this; /** * Removes all listeners, or those of the specified eventName. * * @param eventName The name of the event. Optional if omitted all listeners will be removed. * @returns The Emitter instance. */ removeAllListeners(eventName: string): this; /** * Adds a one time listener function for the event named eventName. The next time eventName is triggered, * this listener is removed and then invoked. * * @param eventName The name of the event. * @param listener Listener fn that handles the evt. * @returns The Emitter instance. */ once(eventName: string, listener: Listener): this; /** * Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, * passing the supplied arguments to each. * * @param eventName The name of the event. * @returns Returns true if the event had listeners, false otherwise. */ emit(eventName: string, ...args: any[]): boolean; }