@barchart/common-js
Version:
Library of common JavaScript utilities
52 lines (51 loc) • 1.45 kB
TypeScript
/**
* An implementation of the observer pattern.
*
* @public
* @extends {Disposable}
*/
export default class Event extends Disposable {
/**
* @param {*} sender - The object which owns the event.
*/
constructor(sender: any);
/**
* Registers an event handler which will receive a notification when
* {@link Event#fire} is called.
*
* @public
* @param {Function} handler - The function which will be called each time the event fires. The first argument will be the event data. The second argument will be the event owner (i.e. sender).
* @returns {Disposable}
*/
public register(handler: Function): Disposable;
/**
* Removes registration for an event handler. That is, the handler will
* no longer be called if the event fires.
*
* @public
* @param {Function} handler
*/
public unregister(handler: Function): void;
/**
* Removes all handlers from the event.
*
* @public
*/
public clear(): void;
/**
* Triggers the event, calling all previously registered handlers.
*
* @public
* @param {*} data - The data to pass each handler.
*/
public fire(data: any): void;
/**
* Returns true if no handlers are currently registered.
*
* @public
* @returns {boolean}
*/
public getIsEmpty(): boolean;
#private;
}
import Disposable from './../lang/Disposable.js';