/** * @class * @description Gives event emitting/listening functionalities to its extenders. * @exports Emitter * @abstract */ export default abstract class Emitter { private _listeners; /** * Sets a listener to a given event. Use {@link emit} to trigger those events. * @param {string} eventName Name of the event. * @param {callback} callback Callback of the event. Receives event and data. * @return {this} Polymorphic with the type of the child class. * @public */ on(eventName: string, callback: callback): this; /** * Removes given callback from the listeners of this object. * @param {string} eventName Name of the event. * @param {callback} callback Callback of the event. * @return {this} Polymorphic with the type of the child class. * @public */ off(eventName: string, callback: callback): this; /** * Emits given event, triggering all the associated callbacks. * @param {string} eventName Name of the event. * @param {object} data Custom data to be sent to the callbacks. * @return {this} Polymorphic with the type of the child class * @protected */ protected emit(eventName: string, data?: unknown): this; }