UNPKG

ste-core

Version:
72 lines (71 loc) 2.42 kB
import { EventListBase, ISubscribable } from ".."; /** * Base class that implements event handling. With a an * event list this base class will expose events that can be * subscribed to. This will give your class generic events. * * @export * @abstract * @class HandlingBase * @template TEventHandler The type of event handler. * @template TDispatcher The type of dispatcher. * @template TList The type of event list. */ export declare abstract class HandlingBase<TEventHandler, TDispatcher extends ISubscribable<TEventHandler>, TList extends EventListBase<TDispatcher>> { protected events: TList; /** * Creates an instance of HandlingBase. * @param {TList} events The event list. Used for event management. * * @memberOf HandlingBase */ constructor(events: TList); /** * Subscribes once to the event with the specified name. * @param {string} name The name of the event. * @param {TEventHandler} fn The event handler. * * @memberOf HandlingBase */ one(name: string, fn: TEventHandler): void; /** * Checks it the event has a subscription for the specified handler. * @param {string} name The name of the event. * @param {TEventHandler} fn The event handler. * * @memberOf HandlingBase */ has(name: string, fn: TEventHandler): boolean; /** * Subscribes to the event with the specified name. * @param {string} name The name of the event. * @param {TEventHandler} fn The event handler. * * @memberOf HandlingBase */ subscribe(name: string, fn: TEventHandler): void; /** * Subscribes to the event with the specified name. * @param {string} name The name of the event. * @param {TEventHandler} fn The event handler. * * @memberOf HandlingBase */ sub(name: string, fn: TEventHandler): void; /** * Unsubscribes from the event with the specified name. * @param {string} name The name of the event. * @param {TEventHandler} fn The event handler. * * @memberOf HandlingBase */ unsubscribe(name: string, fn: TEventHandler): void; /** * Unsubscribes from the event with the specified name. * @param {string} name The name of the event. * @param {TEventHandler} fn The event handler. * * @memberOf HandlingBase */ unsub(name: string, fn: TEventHandler): void; }