Skip to content

Instantly share code, notes, and snippets.

@nic004
Created February 22, 2018 11:36
Show Gist options
  • Select an option

  • Save nic004/29e810fbe9a474ebe806cc0a3588d2bb to your computer and use it in GitHub Desktop.

Select an option

Save nic004/29e810fbe9a474ebe806cc0a3588d2bb to your computer and use it in GitHub Desktop.
promise with ReactiveSwift #3
...
class Promise<Value, Error: Swift.Error> {
...
@discardableResult func started(_ then: @escaping () -> Void) -> Promise<Value, Error> {
sp.on(started: then)
return self
}
@discardableResult func value(_ then: @escaping (Value) -> Void) -> Promise<Value, Error> {
sp.on(value: then)
return self
}
@discardableResult func completed(_ then: @escaping () -> Void) -> Promise<Value, Error> {
sp.on(completed: then)
return self
}
@discardableResult func failed(_ then: @escaping (Error) -> Void) -> Promise<Value, Error> {
sp.on(failed: then)
return self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment