-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import Dispatch | |
func whenAll<Value>(_ promises: [Promise<Value>], notifyOn queue: DispatchQueue = .global()) -> Promise<[Value]> { | ||
return Promise { (fulfill, reject) in | ||
let group = DispatchGroup() | ||
var rejected = false | ||
|
||
for promise in promises { | ||
group.enter() | ||
|
@@ -11,11 +12,15 @@ func whenAll<Value>(_ promises: [Promise<Value>], notifyOn queue: DispatchQueue | |
group.leave() | ||
}.catch { error in | ||
reject(error) | ||
rejected = true | ||
group.leave() | ||
} | ||
} | ||
|
||
group.notify(queue: queue) { | ||
fulfill(promises.map { $0.result!.value! }) | ||
if !rejected { | ||
fulfill(promises.map { $0.result!.value! }) | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
designatednerd
Contributor
|
||
} | ||
} | ||
} | ||
|
else { ?
what about
reject
? doesn't that need to be called?