UNPKG

@barchart/common-js

Version:
69 lines (68 loc) 1.99 kB
/** * A container for {@link Event} instances where each event is * keyed by name. * * @public * @extends {Disposable} */ export default class EventMap extends Disposable { /** * Fires the appropriate event which is mapped to the event name. * See {@link Event#fire} for more information. * * @public * @param {string} eventName - The event's name. * @param {*} data - The data to provide to observers. */ public fire(eventName: string, data: any): void; /** * Registers a handler. See {@link Event#register} for more information. * * @public * @param {string} eventName - The event's name. * @param {Function} handler * @returns {Disposable} */ public register(eventName: string, handler: Function): Disposable; /** * Removes a handler. See {@link Event#unregister} for more information. * * @public * @param {string} eventName - The event's name. * @param {Function} handler */ public unregister(eventName: string, handler: Function): void; /** * Clears an event's handlers. See {@link Event#clear} for more information. * * @public * @param {string} eventName - The event's name. */ public clear(eventName: string): void; /** * Returns true, if no handlers are currently registered for the * specified event. See {@link Event#getIsEmpty} for more information. * * @public * @param {string} eventName * @returns {boolean} */ public getIsEmpty(eventName: string): boolean; /** * Returns an array of all the event names. * * @public * @returns {Array<string>} */ public getKeys(): Array<string>; /** * Returns true, if an event with the given name exists. * * @public * @param {string} key * @returns {boolean} */ public hasKey(key: string): boolean; #private; } import Disposable from './../lang/Disposable.js';