Skip to content

Instantly share code, notes, and snippets.

View rommex's full-sized avatar

rommex

  • Unstoppable Domains
  • X @mamiy
View GitHub Profile
@rommex
rommex / gist:5c6a14114209e1072e9524b1d29c396e
Last active June 17, 2021 21:10
Example with Promises
private func fetchData() -> Promise<[Int]> {
return Promise { seal in
let someData = (1...100_000).map { _ in Int.random(in: (1...100)) }
seal.fulfill(someData)
}
}
private func calculateMinMax(forData array: [Int]) -> Promise<(Int, Int)> {
return Promise { seal in
guard let first = array.first else {