How do I convert:
Observable<List<SomeObject>> to List<SomeObject>
Using this this:
Observable.just(index)
.map { d ->
// returns an Observable<List<someObject>>
}
.observeOn(Schedulers.computation())
.map { r ->
doSomething(r) // r must be converted to a List<someObject>
}
.observeOn(AndroidSchedulers.mainThread())
.take(1)
.subscribe {
}
If you're explicitly returning an Observable<List<SomeObject>>
in your first map
, you should instead use a flatMap
to flatten the observables into one. Otherwise, your first map
is actually returning an Observable<Observable<List<SomeObject>>>
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments