import { AsyncStream, AsyncIterableSubject } from 'data-async-iterators'; import { Semaphore } from "data-semaphore"; /** * @category composable/executors */ export declare class Hookable { hooks: Map; allowImplicitCreation: boolean; has(name: string): boolean; create(name: string): Hook; get(name: string): Hook; subscribe(name: string, subscription: HookSubscription): HookSubscriptionCancellation; unsubscribe(name: string, subscription: HookSubscription): void; notify(name: string, arg?: T): Promise; } /** * @category composable/executors */ export interface HookSubscription { (arg: T): void | Promise; } /** * @category composable/executors */ export interface HookSubscriptionCancellation { (): void; } /** * @category composable/executors */ export declare class Hook { name: string; protected subscriptions: HookSubscription[]; protected notificationSemaphore: Semaphore; allowConcurrentNotifications: boolean; constructor(name: string); setSequential(): this; setParallel(): this; subscribe(callback: HookSubscription): HookSubscriptionCancellation; unsubscribe(callback: HookSubscription): void; isSubscribed(): boolean; notify(arg?: T): Promise; toPromise(errorHook?: Hook): Promise; toAsyncStream(errorHook?: Hook, endHook?: Hook): AsyncStream; [Symbol.asyncIterator](): AsyncIterator; } /** * @category composable/executors */ export declare class HookAsyncIterator extends AsyncIterableSubject implements AsyncIterableIterator { protected release: HookSubscriptionCancellation; protected releaseError: HookSubscriptionCancellation; protected releaseEnd: HookSubscriptionCancellation; constructor(hook: Hook, errorHook?: Hook, endHook?: Hook); protected releaseAllHooks(): void; }