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
()
Methods
reject
(
Void
-
error
Reject a Promise with the given reason.
Parameters:
-
error
ObjectA reason why this Promise rejected.
Returns:
Void:
resolve
(
Void
-
[value=undefined]
Resolve a Promise with the given value.
Parameters:
-
[value=undefined]
Object optionalA value to be resolved by this Promise.
Returns:
Void:
then
(
Promise | TContinuationResult
async
-
onResolved
-
[onRejected=undefined]
Returns a promise. It takes two arguments, both are callback functions for the success and failure cases of the Promise.
Parameters:
-
onResolved
FunctionA function that is called when the Promise is resolved. This function has one argument, the fulfillment value.
-
[onRejected=undefined]
Function optionalA 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.