How do I convert a Flowable to a Single? Or if there's another way to make it stop emitting after the first response that is also of interest.
I've tried this but it doesn't seem to work:
disposables.add(
repository.getAllSomethings()
.subscribeOn(SchedulerProvider.getInstance().computation())
.observeOn(SchedulerProvider.getInstance().ui())
.toSingle()
.subscribeWith(object : DisposableSingleObserver<List<Something>>() {
override fun onSuccess(t: List<Something>) {
}
override fun onError(e: Throwable) {
}
})
getAllSomethings() returns a Flowable<List<Something>>
In the above code .subscribeWith()
is underlined in red complaining that:
Type parameter bound for E in
fun <E : SingleObserver<in Flowable<List<Something>!>!>!> subscribeWith(observer: E!): E!
is not satisfied: inferred type ! is not a subtype of SingleObserver<in Flowable<List<Something>!>!>!