@omnia/fx
Version:
Provide Omnia Fx typings and tooling for clientside Omnia development.
53 lines (52 loc) • 1.95 kB
TypeScript
export declare class Future<T> extends Promise<T> {
resolve: (value: T) => void;
reject: (reason: any) => void;
resolving: boolean;
private _resolved;
private _rejected;
private onAborted;
constructor(executor: (resolve: (value: T) => void, reject: (reason?: any) => void, onAborted: (cb: (reason?: any) => void) => void) => void);
/**
* Handles success / rejection from Promise and returns the result as an object.
* If the promise is rejected, the error will be in the error property.
* No need to try/catch the promise when using this method.
*
* @return {*} {Future<{ success?: T, error?: Error; }>}
* @memberof Future
*/
tryCatch(): Future<[success: T, error: Error]>;
unwrapAxiosApiResponse<T2>(): Future<T2>;
unwrap<T2>(executor: (value: T, resolve: (value: T2) => void, reject: (reason?: any) => void) => void): Future<T2>;
/**
* Expose abort for other future to use.
* chain method for future
* @param onAbort
*/
abortIf(onAbort: (cb: (reason?: any) => void) => void): this;
/**
* Aborts the request
*
* @param {*} [reason]
* @memberof Future
*/
abort(reason?: any): void;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
static all<T extends readonly unknown[] | []>(values: T): Promise<{
-readonly [P in keyof T]: Awaited<T[P]>;
}>;
get resolved(): boolean;
get rejected(): boolean;
static get [Symbol.species](): PromiseConstructor;
get [Symbol.toStringTag](): string;
static new<TReturnValue>(): Future<TReturnValue>;
}
export declare class ResponsePromise<T> extends Promise<T> {
cancelCb: (() => void);
constructor(executor: any);
cancel(): void;
}