Created
February 21, 2018 00:57
-
-
Save banjun/140c1cabb9616160d750f893c1eb3434 to your computer and use it in GitHub Desktop.
create SignalProducer that create Future with the autoclosure on start and send a result to the inner observer
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
extension SignalProducer { | |
// create SignalProducer that create Future with the autoclosure on start and send a result to the inner observer | |
init(_ future: @escaping @autoclosure () -> Future<Value, Error>) { | |
self.init { observer, _ in | |
future() | |
.onSuccess { | |
observer.send(value: $0) | |
observer.sendCompleted()} | |
.onFailure { | |
observer.send(error: $0)} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment