Adds callbacks that will operate on the result of the Thenable, returning a
new child Promise.
If the Thenable is fulfilled, the onFulfilled
callback will be
invoked with the fulfillment value as argument, and the child Promise will
be fulfilled with the return value of the callback. If the callback throws
an exception, the child Promise will be rejected with the thrown value
instead.
If the Thenable is rejected, the onRejected
callback will be invoked with
the rejection reason as argument. Similar to the fulfilled case, the child
Promise will then be resolved with the return value of the callback, or
rejected with the thrown value if the callback throws an exception.
Specified by | |
---|
Parameters | opt_onFulfilled | (function((TYPE|null)): (VALUE|null)|null)= | | A
function that will be invoked with the fulfillment value if the Promise
is fulfilled.
| opt_onRejected | (function(*): *|null)= | | A function that will
be invoked with the rejection reason if the Promise is rejected.
| opt_context | (THIS|null)= | | An optional context object that will be the
execution context for the callbacks. By default, functions are executed
with the default this.
|
|
---|
Returns | RESULT | A new Promise that will receive the result
of the fulfillment or rejection callback.
|
|
---|