Skip to main content
Module

x/evt/lib/types/interfaces/CtxLike.ts

💧EventEmitter's typesafe replacement
Go to Latest
File

import { typeGuard } from "../../../tools/typeSafety/typeGuard.ts";type EvtLike<T> = import("../helper/UnpackEvt.ts").EvtLike<T>;
type Handler<T, U, CtxProp extends CtxLike<any> | undefined = CtxLike<any> | undefined> = import("../Handler.ts").Handler<T, U, CtxProp>;
export const z_3 = { "match": function match<T = any>(o: any): o is CtxLike<T> { return ( typeGuard<CtxLike>(o) && o instanceof Object && typeof o.done === "function" && typeof o.abort === "function" && typeof o.zz__addHandler === "function" && typeof o.zz__removeHandler === "function" ); }}
/** * Minimal interface that an object must implement to be a valid context argument * ( for interop between mismatching EVT versions ) * */export interface CtxLike<Result = any> { done(result: Result): void; abort(error: Error): void; zz__addHandler<T>(handler: Handler<T, any, CtxLike<Result>>, evt: EvtLike<T>): void; zz__removeHandler<T>(handler: Handler<T, any, CtxLike<Result>>): void;}
export namespace CtxLike {
export const match = z_3.match;
}

export interface VoidCtxLike extends CtxLike<void> { done(): void;}