Awesome
FutureProofing
A companion library to BrightFutures with extensions that provides a Future-based alternative to asynchronous API's.
The goal for this library is to become a community driven, best practice, helper-framework that most users of BrightFutures include when using the core library.
This project is inspired by, and based in part on, the PromiseKit extensions.
Extensions sample
UIKit
UIView
UIView.animate(withDuration: 0.5) {
// perform animation
}.onComplete { _ in
// callback executed when the Future returned from animateWithDuration completes
}
Foundation
URLSession
let (task, f): URLSession.FutureSessionDataTask = session.dataTask(with: URL(string: "http://www.example.org")!)
task.resume()
f.onSuccess { (data, response) in
// do something with the response
}.onFailure { error in
// handle error
}
AppKit
NSWindow
let f = window.beginSheet(sheetWindow: sheetWindow)
f.onSuccess { modalResponse in
// do something with the response
}
Installation
CocoaPods
-
Add the following to your Podfile:
pod 'FutureProofing'
-
Integrate your dependencies using frameworks: add
use_frameworks!
to your Podfile. -
Run
pod install
.