Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
RxLifecycle helper
protected fun <T> subscribe(observable: Observable<T>?, observer: Observer<T>?, bind: Boolean = true) {
if (observable != null && observer != null) {
if (bind) {
observable
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread(), true)
.bindToLifecycle(this)
.subscribe(observer)
} else {
observable
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread(), true)
.subscribe(observer)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.