@pricingmonkey/tangi
Version:
Lightweight actor library for Web Workers inspired by Akka
15 lines (14 loc) • 508 B
TypeScript
export declare type KillSwitch = {
isCancelled: boolean;
};
declare type CancellableTask<T> = {
promise: () => Promise<T>;
cancel: () => void;
};
export declare type CancellationOperator = {
register: <T>(contextId: string, id: string, task: (killSwitch: KillSwitch) => Promise<T>) => CancellableTask<T>;
unregister: (contextId: string, id: string) => void;
cancel: (contextId: string) => void;
};
export declare const makeCancellationOperator: () => CancellationOperator;
export {};