Skip to content

Commit

Permalink
fix: solve issue that promise all is not working when array size is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
0xWOF committed Apr 17, 2024
1 parent 5861fec commit 146ed85
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Source/Concurrency/Promise/Composition/PromiseAll.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extension Promise where
promiseReturn.resolve(values)
}

promises.forEach { promise in
for promise in promises {
promise.subscribe(
queue: promise.queue,
onResolved: { _ in resolve() },
Expand All @@ -39,6 +39,10 @@ extension Promise where
)
}

if promises.isEmpty {
resolve()
}

return promiseReturn
}

Expand Down

0 comments on commit 146ed85

Please sign in to comment.