Skip to content

Instantly share code, notes, and snippets.

@oleksii-demedetskyi
Last active June 17, 2016 12:25
Show Gist options
  • Save oleksii-demedetskyi/7a9777531f33046839f4337ce85e7985 to your computer and use it in GitHub Desktop.
Save oleksii-demedetskyi/7a9777531f33046839f4337ce85e7985 to your computer and use it in GitHub Desktop.
extension Future {
func then<U>(f: T -> Future<U>) -> Future<U> {
let promise = Promise<U>()
self.onFail { promise.fail() }.onSuccess {
f($0).onFail { promise.fail() }.onSuccess { promise.resolve($0) }
}
return promise.future
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment