import SingleInvokeEvent from "../Events/SingleInvokeEvent"; import { Undefinable, Awaitable } from "../Types"; /** * The AsyncWrapper is provided to monitor the state of a promise. * You can use this to provide state feedback to the user of an awaitable * method. */ export default class AsyncWrapper { #private; /** * Creates a new unresolved AsyncWrapper */ constructor(); /** * Creates a new AsyncWrapper * @param promiseOrValue can be a promise or a value */ constructor(promiseOrValue: Awaitable); /** * Creates a new AsyncWrapper * @param promiseOrValue can be a promise or a value * @param callback the callback that should be applied after the promise is resolved */ constructor(promiseOrValue: Awaitable, callback: (asyncWrapper: AsyncWrapper) => void); /** * Creates a new AsyncWrapper * @param promiseFactory can be a promise or a value factory that will be invoked immediately */ constructor(promiseFactory: () => Awaitable); /** * Creates a new AsyncWrapper * @param promiseFactory can be a promise or a value factory that will be invoked immediately * @param callback the callback that should be applied after the promise is resolved */ constructor(promiseFactory: () => Awaitable, callback: (asyncWrapper: AsyncWrapper) => void); /** * Creates a new AsyncWrapper * @param promiseOrValueOrFactory can be a promise or a value factory, a value or a promise that will be invoked immediately * @param callback the callback that should be applied after the promise is resolved */ constructor(promiseOrValueOrFactory?: Awaitable | (() => Awaitable), callback?: (asyncWrapper: AsyncWrapper) => void); update(promiseOrValueOrFactory?: (Awaitable | (() => Awaitable) | undefined)): void; /** Event to be fired when the internal promise has completed */ get completeEvent(): SingleInvokeEvent>; /** Return the internal promise that is waiting for the orginal one to complete */ get promise(): Promise; /** returns true when the promise is complete, even if it errored */ get complete(): boolean; /** returns true if the promise completed successfully */ get success(): boolean; /** returns the value of the promise */ get value(): Undefinable; /** returns the error if the promise failed */ get error(): unknown; cancel(): void; }