Swiftpack.co - geekaurora/SwiftPromise as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by geekaurora.
geekaurora/SwiftPromise 1.1.0
Promise library that manages asynchronous tasks elegantly.
⭐️ 1
🕓 2 weeks ago
iOS
.package(url: "https://github.com/geekaurora/SwiftPromise.git", from: "1.1.0")

Promise library that manages asynchronous tasks elegantly.

Usage

  1. then()/catch():
let promise = Promise<String> { (resolve, reject) in
  self.delayAsync {
   resolve("result")
  }
}
promise
.then { result in
 print(result)
}
.catch { error in
 print(error)
}

If then() returns a new Promise, it will be executed correspondingly.

  1. await():
let result = promise.await()
print(result)
  1. all():
let promises = [createPromise(), createPromise(), createPromise()]

Promise.all(promises)
.then { _ in
  print("Completed all promises.")
}.catch { error in
  print("Failed to execute the promises. Error - \(error).")
}

GitHub

link
Stars: 1
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics