UNPKG

ste-core

Version:
52 lines (51 loc) 2.25 kB
import type { ISubscription } from "../events/ISubscription"; import { DispatcherBase } from "./DispatcherBase"; import type { IPropagationStatus } from "./IPropagationStatus"; /** * Dispatcher base for dispatchers that use promises. Each promise * is awaited before the next is dispatched, unless the event is * dispatched with the executeAsync flag. * * @export * @abstract * @class PromiseDispatcherBase * @extends {DispatcherBase<TEventHandler>} * @template TEventHandler The type of event handler. */ export declare abstract class PromiseDispatcherBase<TEventHandler> extends DispatcherBase<TEventHandler> { /** * The normal dispatch cannot be used in this class. * * @protected * @param {boolean} executeAsync `True` if the even should be executed async. * @param {*} scope The scope of the event. The scope becomes the `this` for handler. * @param {IArguments} args The arguments for the event. * @returns {(IPropagationStatus | null)} The propagation status, or if an `executeAsync` is used `null`. * * @memberOf DispatcherBase */ protected _dispatch(executeAsync: boolean, scope: any, args: IArguments): IPropagationStatus | null; /** * Crates a new subscription. * * @protected * @param {TEventHandler} handler The handler. * @param {boolean} isOnce Indicates if the handler should only run once. * @returns {ISubscription<TEventHandler>} The subscription. * * @memberOf PromiseDispatcherBase */ protected createSubscription(handler: TEventHandler, isOnce: boolean): ISubscription<TEventHandler>; /** * Generic dispatch will dispatch the handlers with the given arguments. * * @protected * @param {boolean} executeAsync `True` if the even should be executed async. * @param {*} scope The scope of the event. The scope becomes the `this` for handler. * @param {IArguments} args The arguments for the event. * @returns {(IPropagationStatus | null)} The propagation status, or if an `executeAsync` is used `null`. * * @memberOf DispatcherBase */ protected _dispatchAsPromise(executeAsync: boolean, scope: any, args: IArguments): Promise<IPropagationStatus | null>; }