|
@@ -61,6 +61,18 @@ extern class Promise<T> {
|
|
|
**/
|
|
|
static function all(iterable:Array<Dynamic>):Promise<Array<Dynamic>>;
|
|
|
|
|
|
+ /**
|
|
|
+ Returns a promise that resolves after all of the given promises have either fulfilled or rejected,
|
|
|
+ with an array of objects that each describes the outcome of each promise.
|
|
|
+
|
|
|
+ It is typically used when you have multiple asynchronous tasks that are not dependent on one another
|
|
|
+ to complete successfully, or you'd always like to know the result of each promise.
|
|
|
+
|
|
|
+ In comparison, the Promise returned by `Promise.all` may be more appropriate if the tasks are dependent
|
|
|
+ on each other / if you'd like to immediately reject upon any of them rejecting.
|
|
|
+ **/
|
|
|
+ static function allSettled(iterable:Array<Dynamic>):Promise<Array<PromiseSettleOutcome>>;
|
|
|
+
|
|
|
/**
|
|
|
Returns a promise that fulfills or rejects as soon as one of the
|
|
|
promises in the iterable fulfills or rejects, with the value or reason
|
|
@@ -116,3 +128,14 @@ abstract Thenable<T>(ThenableStruct<T>)
|
|
|
typedef ThenableStruct<T> = {
|
|
|
function then<TOut>(onFulfilled:Null<PromiseHandler<T, TOut>>, ?onRejected:PromiseHandler<Dynamic, TOut>):Thenable<TOut>;
|
|
|
}
|
|
|
+
|
|
|
+typedef PromiseSettleOutcome = {
|
|
|
+ var status:PromiseSettleStatus;
|
|
|
+ var ?value:Dynamic;
|
|
|
+ var ?reason:Dynamic;
|
|
|
+}
|
|
|
+
|
|
|
+enum abstract PromiseSettleStatus(String) to String {
|
|
|
+ var Fulfilled = "fulfilled";
|
|
|
+ var Rejected = "rejected";
|
|
|
+}
|