A lightweight Swift library for writing async code using Promises, Async/Await, and modern operators like all, any, map, zip, and retry.
Hydra is a full-featured Promise library for Swift that enables developers to write cleaner, more manageable asynchronous code. It implements the JavaScript A+ Promise specification and adds modern constructs like async/await, allowing async operations to be written in a synchronous style to avoid callback hell.
Swift developers building iOS, macOS, tvOS, watchOS, or Linux applications who need to handle asynchronous operations such as network requests, file I/O, or complex async workflows.
Developers choose Hydra for its lightweight yet comprehensive feature set, including cancellable promises, a wide range of operators (like all, any, map, zip, timeout, retry), and async/await support that mirrors modern JavaScript and C# patterns, improving code readability and reducing complexity.
⚡️ Lightweight full-featured Promises, Async & Await Library in Swift
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implements async/await patterns similar to JavaScript and C#, allowing developers to write asynchronous code in a synchronous style, as demonstrated in the async and Hydra.await() examples.
Includes operators like all, any, map, zip, timeout, and retry, facilitating complex async workflows such as handling race conditions or retrying failed operations, detailed in the features section.
Supports invalidation tokens for canceling promises from outside, useful for tasks like UITableViewCell image downloads, with examples provided in the cancellable promises section.
Described as a lightweight library compatible with iOS, macOS, tvOS, watchOS, and Linux, making it versatile for various Swift projects.
The update to version 0.9.7 required changes to Promise body signatures, as admitted in the 'Updating to >=0.9.7' section, which can disrupt existing codebases and increase migration effort.
The await function uses semaphores and can cause deadlocks if called in the main thread, as warned in the async/await section, requiring careful thread management to avoid UI freezes.
Implementing cancellable promises requires manual checks for operation status and proper handling, adding complexity and potential for errors, as shown in the detailed cancellable promises example.
With Swift's native concurrency features evolving (e.g., Swift 5.5+), Hydra might become less necessary over time, leading to maintenance overhead for teams adopting it.