API Docs for: 1.0.0
Show:

Promise Class

The Promise object is used for deferred and asynchronous computations. A Promise represents an operation that hasn't completed yet, but is expected in the future.

Constructor

Promise

()

Item Index

Methods

Methods

reject

(
  • error
)
Void

Reject a Promise with the given reason.

Parameters:

  • error Object

    A reason why this Promise rejected.

Returns:

Void:

resolve

(
  • [value=undefined]
)
Void

Resolve a Promise with the given value.

Parameters:

  • [value=undefined] Object optional

    A value to be resolved by this Promise.

Returns:

Void:

then

(
  • onResolved
  • [onRejected=undefined]
)
Promise | TContinuationResult async

Returns a promise. It takes two arguments, both are callback functions for the success and failure cases of the Promise.

Parameters:

  • onResolved Function

    A function that is called when the Promise is resolved. This function has one argument, the fulfillment value.

  • [onRejected=undefined] Function optional

    A function called when the Promise is rejected. This function has one argument, the rejection reason.

Returns:

Promise | TContinuationResult:

where TContinuationResult is the type of the result produced by the chaining.