Skip to content

Instantly share code, notes, and snippets.

@llinardos
Created May 8, 2018 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llinardos/fe52f70414944cf2d7a5f37d67eadaae to your computer and use it in GitHub Desktop.
Save llinardos/fe52f70414944cf2d7a5f37d67eadaae to your computer and use it in GitHub Desktop.
protocol ThingsServiceDelegate {
func service(_ ThingsService, didFinishWithResult: Result<[Thing]>)
}
class ThingsService {
private var delegate: ThingsServiceDelegate
init(with delegate: ThingsServiceDelegate) {
self.delegate = delegate
}
func getThings() {
sendHttpRequest {
var result: Result<[Thing]> = ...
...
delegate.service(self, didFinishWithResult: result)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment