Swift had closures and nothing else. Any flow with three dependent calls became a staircase of completion handlers where error handling was copied into every branch, and cancelling halfway was simply not modelled.
Hydra
Before async/await, a lightweight promise library to write async code that reads top to bottom.
Superseded by Swift concurrency·Swift·since 2017
- –stars
- –forks
- –license
- –last push
In one look
loginUser(username, pass).then { user in
print("Welcome \(user.username)")
}.catch { error in
print("Cannot login \(error)")
}.always {
hideLoadingHUD()
}What it does
-
Promises that compose
then, catch and always, chained top to bottom instead of nested in closures.
-
The operators you kept rewriting
all, any, retry, timeout and zip, once, tested.
-
Cancellation modelled
Stopping halfway is a first-class concept, not a boolean checked by hand.