Reputation: 29885
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 {
}
Upvotes: 1
Views: 39
Reputation: 3331
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>>>
.
Upvotes: 2