Last active
May 8, 2018 14:36
-
-
Save andynovak12/9f5674ee5ccfb6375924c06222320283 to your computer and use it in GitHub Desktop.
Wrapped Asynchronous Function with ReactiveSwift
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
// Wrapping Asynchronous Function | |
func wrappedFunction() -> SignalProducer<String, MockError> { | |
return SignalProducer { observer, disposable in | |
mockAsyncFunction { (optionalReturnedString, optionalReturnedError) in | |
if let returnedString = optionalReturnedString { | |
observer.send(value: returnedString) | |
observer.sendCompleted() | |
} else if let returnedError = optionalReturnedError { | |
observer.send(error: returnedError) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment