A Promise library for Swift that simplifies asynchronous programming with chainable operations and error handling.
Promise is a Swift library that implements the Promise pattern for handling asynchronous operations. It allows developers to represent future values that may succeed or fail, enabling chainable transformations, error handling, and composition of async tasks like HTTP requests. The library simplifies async code by providing methods like `then`, `catch`, and `all` to manage dependencies and concurrency.
Swift developers building iOS, macOS, or server-side applications who need to manage asynchronous operations such as network requests, file I/O, or other tasks that can succeed or fail once.
Developers choose Promise for its simplicity and Swift-friendly design, offering intuitive chainable APIs, automatic error conversion from thrown errors, and flexible threading control without the complexity of typed errors or monadic terminology.
A Promise library for Swift, based partially on Javascript's A+ spec
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses `then` for sequencing async tasks, making code readable and reducing boilerplate compared to nested callbacks, as shown in the basic usage examples where chains handle dependent operations cleanly.
Automatically converts thrown errors into promise rejections, integrating seamlessly with Swift's native error handling, which simplifies working with throwing APIs like JSONSerialization.
Allows specifying queues per block with the `on:` parameter, enabling precise thread control for UI updates and background work, with sensible defaults to the main thread for safety.
Includes static methods like `Promises.all` for concurrency, `race`, `retry`, and `recover` for handling complex async patterns, detailed in the advanced usage section.
No built-in mechanism to cancel in-flight promises, which can lead to resource leaks if not manually managed, a common feature missing compared to other async libraries.
Errors are not parameterized, reducing compile-time safety and requiring pattern matching in catch blocks, a design trade-off the README acknowledges for ease of use.
With InvalidatableQueue, incorrect chaining can leave promises permanently pending, as warned in the README, potentially causing memory issues and stalled operations.