Interface AwaitResponse<T, R>

A Simple type which identifies the result of a promise as a single response, it identifies if the promise was rejected or resolved along with the resolved value or rejected reason. It is a union of the IPromiseFulfilledResult and IPromiseRejectedResult interfaces the response will contain the rejected property which will be true if the promise was rejected or false if the promise was resolved. The status property will be set to either "fulfilled" or "rejected" to identify the status of the promise. The value or reason properties will contain the resolved value or rejected reason respectively.

const result: AwaitResponse<number> = {
status: "fulfilled",
value: 42
};

const result: AwaitResponse<number> = {
rejected: true,
status: "rejected",
reason: "Hello Darkness"
};
interface AwaitResponse<T, R> {
    reason?: R;
    rejected?: boolean;
    status: "fulfilled" | "rejected";
    value?: T;
}

Type Parameters

  • T

    The type of the fulfilled value.

  • R = any

Properties

reason?: R

The reason that the promise was rejected with.

rejected?: boolean

Identifies if the promise was rejected (true) or was resolved (false/undefined)

status: "fulfilled" | "rejected"

A string indicating that the promise was rejected.

value?: T

The value that the promise was fulfilled with.