then()method to hook up a callback that will be called when the result of the asynchronous operation is ready.
Creates a new Promise. The Promise constructor calls
executer immediately with the two functions
executor should begin the asynchronous operation. When the operation is complete, call the
resolve function with the result. If there is an error during the operation, call
reject with the error information.
onResolve (if provided) to be called when the promise has been resolved.
value is the object passed to the
onReject (if provided) to be called when the promise has been rejected or an exception was thrown in the
error is the object passed to the
The return value from
onReject) can either be a normal Object or a Promise. If the return value from
onResolve is a normal Object, the Promise returned by
then() will be resolved with that Object. If the return value from
onResolve is a Promise,
then() will wait for that Promise to be resolved.
then() will resolve the Promise it returned with the same value.
Creates a new Promise that will be resolved when all of
promises are resolved. If any of the promises are rejected, the returned Promise will be rejected immediately and will provide the value of the Promise that was rejected.
Creates a new Promise that will be resolved when the first of
promises is resolved. If a promises is rejected before any resolve, the returned Promise will be rejected immediately and will provide the value of the Promise that was rejected.
Returns a new Promise that is in the rejected state with
error as the rejected error. Useful for passing values to APIs that expect promises.