UNPKG

@eclipse-scout/core

Version:
57 lines 3.03 kB
/// <reference types="jquery" /> import { Event, EventHandler, EventListener } from '../index'; export type EventSubTypePredicate = (type: Event, subType: string) => boolean; export declare class EventSupport { protected _eventListeners: EventListener[]; protected _subTypePredicates: EventSubTypePredicate[]; constructor(); protected _assertFunc(func: EventHandler): void; /** * Registers the given event handler for the event specified by the type param. * * @param type One or more event names separated by space. * @param func Event handler executed when the event is triggered. An event object is passed to the function as first parameter. * @param origFunc Used internally when func is registered with {@link one}. The property is set on the listener * object so the event-handler can be de-registered by using the original function. */ on(type: string, func: EventHandler, origFunc?: EventHandler): EventListener; /** * Registers the given event handler for the event specified by the type param. * The function will only be called once. After that it is automatically de-registered using {@link off}. * * @param type One or more event names separated by space. * @param func Event handler executed when the event is triggered. An event object is passed to the function as first parameter */ one(type: string, func: EventHandler): EventListener; /** * De-registers the given event handler for the event specified by the type param. * * @param type One or more event names separated by space.<br/> * Important: the string must be equal to the one used for {@link on} or {@link one}. This also applies if a string containing multiple types separated by space was used. * @param func The exact same event handler that was used for registration using {@link on} or {@link one}. * If no handler is specified, all handlers are de-registered for the given type. */ off(type: string, func?: EventHandler): void; /** * Adds an event handler using {@link one} and returns a promise. * The promise is resolved as soon as the event is triggered. */ when(type: string): JQuery.Promise<Event>; addListener(listener: EventListener): void; removeListener(listener: EventListener): void; count(type?: string, func?: EventHandler): number; /** * @returns the event types of the registered listeners */ types(): string[]; trigger(type: string, event?: Event): void; protected _typeMatches(event: Event, listenerType: string): boolean; protected _subTypeMatches(event: Event, listenerType: string): boolean; /** * * @param type the type which could contain a subtype * @param predicate the predicate which will be tested when an event with the given type is triggered. */ registerSubTypePredicate(type: string, predicate: EventSubTypePredicate): void; } //# sourceMappingURL=EventSupport.d.ts.map