Created
May 8, 2018 19:02
-
-
Save llinardos/fe52f70414944cf2d7a5f37d67eadaae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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