ts-audio
Version:
`ts-audio` is an agnostic and easy-to-use library to work with the `AudioContext` API and create Playlists.
38 lines (37 loc) • 1.17 kB
TypeScript
/**
* Represents an event with associated data.
*/
export type Event = {
/**
* The data associated with the event. The type of data is unknown.
*/
data: unknown;
};
/**
* Event emitter class that allows registering event listeners and emitting events.
*/
export declare class EventEmitter {
/**
* A map of event keys to their respective callback functions.
* @private
*/
private events;
/**
* Initializes a new instance of the EventEmitter class.
*/
constructor();
/**
* Registers a listener for a specific event key.
*
* @param {string} keyEvent - The key of the event to listen for.
* @param {(param: Event) => void} callback - The callback function to be invoked when the event is emitted.
*/
listener(keyEvent: string, callback: (param: Event) => void): void;
/**
* Emits an event, invoking the corresponding listener with the provided parameter.
*
* @param {string} keyEvent - The key of the event to emit.
* @param {Event} param - The parameter to pass to the event's callback function.
*/
emit(keyEvent: string, param: Event): void;
}