Home

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.

Join the chat at https://gitter.im/Thomvis/BrightFutures Carthage compatible CocoaPods version

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

  1. Add the following to your Podfile:

    pod 'FutureProofing'
    
  2. Integrate your dependencies using frameworks: add use_frameworks! to your Podfile.

  3. Run pod install.

Carthage

  1. Add the following to your Cartfile:

    github "Thomvis/FutureProofing"
    
  2. Run carthage update and follow the steps as described in Carthage's README.