This repository was archived by the owner on Jan 16, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +21
-4
lines changed
Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 11Pod ::Spec . new do |s |
22 s . name = 'Promises'
3- s . version = '1.0.0 '
3+ s . version = '1.0.1 '
44 s . summary = 'I promise the future!'
55 s . description = <<-DESC
66 It's just another Promise library that works on
Original file line number Diff line number Diff line change @@ -13,12 +13,12 @@ pod 'Promises'
1313
1414### SPM
1515```
16- .package(url: "https://github.com/CoreKit/Promises.git", from: "1.0.0 "),
16+ .package(url: "https://github.com/CoreKit/Promises.git", from: "1.0.1 "),
1717```
1818
1919### Carthage
2020```
21- github "CoreKit/Promises" "1.0.0 "
21+ github "CoreKit/Promises" "1.0.1 "
2222```
2323
2424## Pod cheatsheet
Original file line number Diff line number Diff line change @@ -352,7 +352,24 @@ public enum Promises {
352352 }
353353 }
354354 }
355-
355+
356+ @discardableResult
357+ public static func wait< T> ( _ promises: [ Promise < T > ] ) -> Promise < Void > {
358+ return Promise< Void> { fulfill, _ in
359+ guard !promises. isEmpty else {
360+ return fulfill ( ( ) )
361+ }
362+ let complete : ( ( Any ) -> Void ) = { _ in
363+ if !promises. contains ( where: { $0. isPending } ) {
364+ fulfill ( ( ) )
365+ }
366+ }
367+ for promise in promises {
368+ promise. then ( success: complete, failure: complete)
369+ }
370+ }
371+ }
372+
356373 @discardableResult
357374 public static func race< T> ( _ promises: [ Promise < T > ] ) -> Promise < T > {
358375 return Promise< T> { fulfill, reject in
You can’t perform that action at this time.
0 commit comments