Skip to content

Instantly share code, notes, and snippets.

@ericntd
Last active May 31, 2021 20:10
Show Gist options
  • Save ericntd/dc6be17eb3499945e4403a7e8e430df7 to your computer and use it in GitHub Desktop.
Save ericntd/dc6be17eb3499945e4403a7e8e430df7 to your computer and use it in GitHub Desktop.
Typical Room RxJava read stream and presentation of data
schoolDAO.getData() // Flowable
.subscribeOn(schedulerProvider.io())
.doOnSubscribe { showProgressSpinner() }
.flatMapSingle { school -> getExtraData(school) }
.observeOn(schedulerProvider.ui())
.subscribe({ data ->
hideProgressSpinner()
updateUi(data)
}, { throwable ->
hideProgressSpinner()
handleError(throwable)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment