///
import { EventEmitter } from 'events';
export declare enum EDependencyKind {
Pass = 0,
Fail = 1,
Both = 2,
}
export declare enum ERunningStatus {
None = 0,
Waiting = 1,
Running = 2,
Ended = 3,
Canceled = 4,
}
export declare const RunnableListener: EventEmitter;
export declare const RunnableEvents: {
RunningStatusChanged: string;
Resolved: string;
Rejected: string;
Canceling: string;
};
export declare class Runnable {
protected runner: (runnable: Runnable) => Promise;
private _cancellationListeners;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @returns A Promise for the completion of which ever callback is executed.
*/
then(onfulfilled?: (value: T) => TResult | PromiseLike): Promise;
then(onfulfilled?: (value: T) => TResult | PromiseLike): Promise;
then(onfulfilled?: (value: T) => TResult | PromiseLike, onError?: (reason: any) => T | PromiseLike | void): Promise;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(runnable?: (reason: any) => T | PromiseLike): Promise;
catch(runnable?: (reason: any) => void): Promise;
thenOrCatch(): Promise<{
runnable: Runnable;
failed: boolean;
value?: T;
error?: any;
}>;
addDependency(runnable: Runnable, kind?: EDependencyKind): void;
dependsOn: {
runnable: Runnable;
kind: EDependencyKind;
}[];
id: string;
name: string;
protected _resolve: any;
protected _reject: any;
innerPromise: Promise;
constructor(runner: (runnable: Runnable) => Promise);
value: T;
error: Error;
resolved: boolean;
rejected: boolean;
runningStatus: ERunningStatus;
cancel(): void;
onCancel(fn: () => void): void;
run(triggerExecution?: boolean): void;
private setRunningStatus(status);
}
export default Runnable;