import { Handler } from "./types/Handler"; import { Evt } from "./Evt"; declare type EvtCore = import("./EvtCore").EvtCore; declare type Done = [Error | null, T, Handler.WithEvt[]]; export declare class Ctx { /** Posted each time ctx.done() is invoked, post the detached handler ( return value of evt.done()) */ readonly getEvtDone: () => Evt>; /** * Return a promise that resolve next time ctx.done(result) is invoked * Reject if ctx.abort(error) is invoked. * Optionally a timeout can be passed, if so the returned promise will reject * with EvtError.Timeout if done(result) is not called * within [timeout]ms. * If the timeout is reached ctx.abort(timeoutError) will be invoked. */ getPrDone(timeout?: number): Promise; /** Posted every time a handler is bound to this context */ readonly getEvtAttach: () => Evt>; /** Posted every time a handler bound to this context is detached from it's Evt */ readonly getEvtDetach: () => Evt>; private readonly onDone; private readonly onAttach; private readonly onDetach; constructor(); /** * All the handler will be detached. * evtDone will post [ error, undefined, handlers (detached) ] * if getPrDone() was invoked the promise will reject with the error */ abort(error: Error): Handler.WithEvt[]; /** * Detach all handlers. * evtDone will post [ null, result, handlers (detached) ] * If getPrDone() was invoked the promise will result with result */ done(result: T): Handler.WithEvt[]; /** Detach all handler bound to this context from theirs respective Evt and post getEvtDone() */ private __done; private handlers; private evtByHandler; getHandlers(): Handler.WithEvt[]; static __addHandlerToCtxCore(handler: Handler>, evt: EvtCore): void; static __removeHandlerFromCtxCore(handler: Handler): void; static __matchHandlerBoundToCtx(handler: Handler): handler is Handler; } export declare class VoidCtx extends Ctx { /** * Detach all handlers. * evtDone will post [ null, undefined, handlers (detached) ] * If getPrDone() was invoked the promise will resolve */ done(): ReturnType; } export {};