Created
February 23, 2018 09:28
-
-
Save nic004/a50a1f5a8ee6d5749c2f62ad0152fe49 to your computer and use it in GitHub Desktop.
callback using ReactiveSwift
This file contains hidden or 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
| func job() -> SignalProducer<Int, NoError> { | |
| return SignalProducer<Int, NoError> { observer, disposable in | |
| DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(10)) { | |
| observer.send(value: 300) | |
| observer.sendCompleted() | |
| } | |
| } | |
| } | |
| job().on(value: { v in | |
| print(v) | |
| }).on(completed: { | |
| print("completed") | |
| }).start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment