Promises for asynchronous code in Swift and Objective-C
open sourceApache-2.0free
Promises is Google's framework that brings promises to Objective-C and Swift for writing asynchronous code. Promises created in one language can be used in the other, observer blocks run on any thread or dispatch queue, and its overhead is close to GCD and completion handlers. It has extensions such as all, any, race, retry, timeout, delay and recover, and a testing helper. It targets macOS, iOS, tvOS and watchOS and installs with SwiftPM, CocoaPods, Carthage or Bazel.
Problems it solves
- avoid nested completion handlers in an iOS app
- chain asynchronous calls in Objective-C and Swift code that share types
- retry or time out an async operation in Swift
Features
- Promises usable across Objective-C and Swift
- Observer blocks dispatched on any thread or custom queue
- Overhead close to GCD and completion handlers
- Extensions such as all, any, race, retry, timeout, delay and recover
- Installs with SwiftPM, CocoaPods, Carthage or Bazel
Alternatives
The same job
These do what Promises (Google) does.
- Queuer Queue manager for Swift on OperationQueue and GCD
- Swift Atomics Low-level atomic operations for Swift
