Promise static api usage summary

Promise static method

allSettled   the result is an array of objects, a consistent order of the values of the order and the array of objects incoming Promise.

All promise to return the results can only get in then, no execution catch.

Each object contains

status (Promise state),

value (Promise successful implementation of the results),

reason (Promise execution result of the failure).

 

all    returned results, depending on the situation Promise of execution,

If there is a promise of greater than equal to error, error trapping in the catch is thrown in,

Wrong information is information of the first to reject a single promise.

If all of the promise are executed successfully, the value will return results all promise execution,

And the order of the array and the same value when the value of the order of incoming Promise.

 

race  returns the result, when there is an array of objects Promise Promise executed, race corresponding method is executed.

Promise of reject or resolve callback method executes the first response immediately, the result is that the value of the Promise fastest execution.

Only a value of resolve or reject.

 

Note: allSettled, All, Race method itself is return Promise objects [object Promise], but then only one catch method will be called, but also can have more then need to return value.

Guess you like

Origin www.cnblogs.com/the-last/p/12048348.html