import { Event, EventHandler, EventListener } from '../index'; export declare class EventSupport { protected _eventListenersByType: Map>; protected _eventListenersByHandler: Map>, Set>; protected _subTypeProviders: Map; protected _sortIndex: number; 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.
* 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; /** * Adds the given {@link EventListener} if it is not present. */ addListener(listener: EventListener): void; /** * Removes the given {@link EventListener} if it is present. */ removeListener(listener: EventListener): void; /** * Counts all {@link EventListener}s that match the given filters. * * The type-filter will match all listeners that are triggered by all given types. * For example if there are two listeners registered with type 'lorem' and 'lorem ipsum dolor' the filter 'lorem' will match 2 listeners. * In this example, the type-filter 'ipsum dolor' will match 1 listener like 'dolor' or 'dolor ipsum lorem'. * * The func-filter will match all listeners that are registered using this exact {@link EventHandler}. */ count(type?: string, func?: EventHandler): number; /** * Returns a list of unique single types of all registered listeners. * Example: If there are two listeners registered for 'lorem' and 'lorem ipsum dolor' the multi-type is split and ['lorem', 'ipsum', 'dolor'] is returned. */ types(): string[]; trigger(type: string, event?: Event): void; /** * Gets a {@link Set} of {@link EventListenerWithSortIndex}s for the requested type. * The result of this method is never `null`. * If the create-flag is set, the {@link Set} is added to {@link _eventListenersByType}. */ protected _getListenersByType(type: string, create?: boolean): Set; /** * Adds an {@link EventListenerWithSortIndex} to {@link _eventListenersByType} for the given identifier. */ protected _addListenerByType(type: string, listener: EventListenerWithSortIndex): void; /** * Removes an {@link EventListenerWithSortIndex} from {@link _eventListenersByType} for the given identifier. */ protected _removeListenerByType(type: string, listener: EventListenerWithSortIndex): void; /** * Gets a {@link Set} of {@link EventListenerWithSortIndex}s for the requested {@link EventHandler}. * The result of this method is never `null`. * If the create-flag is set, the {@link Set} is added to {@link _eventListenersByHandler}. */ protected _getListenersByHandler(handler: EventHandler, create?: boolean): Set; /** * Adds an {@link EventListenerWithSortIndex} to {@link _eventListenersByHandler} for the given identifier. */ protected _addListenerByHandler(handler: EventHandler, listener: EventListenerWithSortIndex): void; /** * Removes an {@link EventListenerWithSortIndex} from {@link _eventListenersByHandler} for the given identifier. */ protected _removeListenerByHandler(handler: EventHandler, listener: EventListenerWithSortIndex): void; /** * Gets a {@link Set} of {@link EventListenerWithSortIndex}s for the requested identifier from the given {@link Map}. * The result of this method is never `null`. * If the create-flag is set, the {@link Set} is added to the {@link Map}. */ protected _getListenersByIdentifier(listenerMap: Map>, identifier: TIdentifier, create?: boolean): Set; /** * Adds an {@link EventListenerWithSortIndex} to the given {@link Map} for the given identifier. */ protected _addListenerByIdentifier(listenerMap: Map>, identifier: TIdentifier, listener: EventListenerWithSortIndex): void; /** * Removes an {@link EventListenerWithSortIndex} from the given {@link Map} for the given identifier. */ protected _removeListenerByIdentifier(listenerMap: Map>, identifier: TIdentifier, listener: EventListenerWithSortIndex): void; /** * Splits the given type into unique single types (e.g.: 'lorem ipsum dolor' -> ['lorem', 'ipsum', 'dolor']). */ protected _splitTypes(type: string): Set; /** * Registers a {@link EventSubTypeProvider} for a specific event type. */ registerSubTypeProvider(type: string, provider: EventSubTypeProvider): void; } export type EventListenerWithSortIndex = EventListener & { _sortIndex?: number; }; /** * Builds a complete type for an {@link Event}. * Consider a `FancyEvent` that is always triggered with the type 'fancy' but has a property `subType` which can hold the values 'foo' or 'bar'. * If there is an {@link EventSubTypeProvider} returning this `subType`, listeners registered for 'fancy:foo' or 'fancy:bar' will be executed when the `subType` matches. */ export type EventSubTypeProvider = (type: Event) => string; //# sourceMappingURL=EventSupport.d.ts.map