Skip to content

Instantly share code, notes, and snippets.

@luks91
Last active November 23, 2017 14:16
Show Gist options
  • Save luks91/d70b19abd60f630afc64e50e89948d83 to your computer and use it in GitHub Desktop.
Save luks91/d70b19abd60f630afc64e50e89948d83 to your computer and use it in GitHub Desktop.
fun save(contacts: Flowable<Contact>) =
contacts
.observeOn(Schedulers.io())
.subscribe(object : DefaultSubscriber<Contact>() {
override fun onStart() = request(1)
override fun onNext(contact: Contact) =
openConnection<Contact>().use {
it.write(contact)
request(1)
}
override fun onComplete() {}
override fun onError(t: Throwable) {
Log.e("TAG", "Oops!", t)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment