@liberquack/utils
Version:
Quack utilities
16 lines (15 loc) • 609 B
TypeScript
import { Undefinable } from "../../../_/types.js";
declare type useAwaitReturnType<T extends ((...args: any[]) => Promise<R>), R> = {
run: T;
result: Undefinable<R>;
loading: boolean;
err: undefined | Error;
};
declare type useAwaitType<T extends ((...args: any[]) => Promise<R>), R> = useAwaitReturnType<T, R>;
/**
*
* @param job Async function to be executed
* @param cb Callback executed everytime the stats change
*/
export declare function useAwait<R, T extends ((...args: any[]) => Promise<R>)>(job: T, cb?: (stats: useAwaitReturnType<T, R>) => void): useAwaitType<T, R>;
export {};