UNPKG

onix-core

Version:
87 lines (86 loc) 2.66 kB
import { IDisposable, ITyped } from '../Types'; import { IEventArgs, IEventArgs1 } from './IEventArgs'; import { IEventHandler, IEventHandler1 } from './IEventHandler'; import { IEvent, IEvent1 } from './IEvent'; export declare class Event implements IDisposable, ITyped, IEvent { _type: string; private handlers; OnHandlerAttached: () => void; OnHandlerAttachedContext: any; OnHandlerDettached: () => void; OnHandlerDettachedContext: any; /** * constructor */ constructor(); /** * Determines whether the specified handler is bound to the event. */ hasBinding(handler: IEventHandler): boolean; /** * Determines whether the Event has active bindings. */ hasBindings(): boolean; /** * Associates the handler with the Event object. * @param handler Event handler. */ bind(handler: IEventHandler): void; /** * Associates the event handler with the Event object to execute no more than the specified number of times. * After the specified number of times, the action is disconnected from the handler. * @param handler Event handler. * @param triggerCount Number of calls before the handler is disconnected. */ bindFor(handler: IEventHandler, triggerCount: number): void; /** * Disconnects the specified handler from the Event. * @param handler Event handler. */ unbind(handler: IEventHandler): void; /** * Executes all linked handlers. */ trigger(args: IEventArgs): void; /** * Make arguments and execute * @param sender Event sender * @param data Event data */ fire(sender: any, data?: any): void; /** * Deletes an event and deletes the binding of all related handlers. */ dispose(): void; } export declare class Event1<T> extends Event implements IEvent1<T> { _type: string; /** * Event handlers */ Handlers: IEventHandler1<T>[]; /** * Associates the handler with the Event object. * @param handler Event handler. */ bind(handler: IEventHandler1<T>): void; /** * Disconnects the specified handler from the Event. * @param handler Event handler. */ unbind(handler: IEventHandler1<T>): void; /** * Determines whether the specified handler is bound to the event. */ hasBinding(handler: IEventHandler1<T>): boolean; /** * Executes all linked handlers. */ trigger(args: IEventArgs1<T>): void; /** * Make arguments and execute * @param sender Event sender * @param data Event data */ fire(sender: any, data: T): void; }