@cygnus-reach/reach-protocol
Version:
Improve the Reachâ„ remote support experience with straightforward device interactions via the Reach Protocol.
56 lines (55 loc) • 2.05 kB
TypeScript
/**
* A CompletablePromise is a Promise whose fulfillment or rejection
* can be triggered externally.
*
* @param T - the type of the object the promise can be fulfilled with.
*/
export declare class CompletablePromise<T> implements Promise<T>, PromiseLike<T> {
/**
* Create a new CompletablePromise that is already in the fulfilled state.
*
* @param value - the value to fulfill the promise with.
*/
static resolved<U>(value: U): CompletablePromise<U>;
[Symbol.toStringTag]: string;
/** Backing promise object. */
private promise;
/** The current state of the backing promise object. */
private stateField;
/**
* Construct a new CompletablePromise.
*/
constructor();
/**
* Get the current state of the CompletablePromise.
*
* @returns 'pending' | 'resolved' | 'rejected'.
*/
get state(): "pending" | "resolved" | "rejected";
/**
* Fulfill the completable promise with some value.
*
* @param value - The value to fulfill the promise with.
*/
fulfill: (value: T | PromiseLike<T>) => void;
/**
* Reject the completable promise with an error.
*
* @param reason - The reason to reject the completable promise.
*/
reject: (reason?: any) => void;
/**
* Attaches a single callback for both the resolution and rejection
* of the promise.
*/
finally(onfinally?: (() => void) | null | undefined): Promise<T>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
*/
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
/**
* Attaches callbacks for just the rejection of the Promise.
*/
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
wait(): Promise<T>;
}