Skip to content

Instantly share code, notes, and snippets.

@nic004
Created February 23, 2018 09:28
Show Gist options
  • Select an option

  • Save nic004/a50a1f5a8ee6d5749c2f62ad0152fe49 to your computer and use it in GitHub Desktop.

Select an option

Save nic004/a50a1f5a8ee6d5749c2f62ad0152fe49 to your computer and use it in GitHub Desktop.
callback using ReactiveSwift
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