I answered another similar question: fooobar.com/questions/195966 / ...
I copied the answer here for convenience (not sure if this is against the rules):
If you want to keep the Lists emitted by the Observable source, but convert the contents, i.e. Observable<List<SourceObject>> in Observable<List<ResultsObject>> , you can do something like this:
Observable<List<SourceObject>> source = ... source.flatMap(list -> Observable.fromIterable(list) .map(item -> new ResultsObject(item)) .toList() .toObservable()
This provides a couple of things:
- The number of
Lists emitted by the Observable . those. if the source emits 3 lists, the other end will have 3 converted lists. - Using
Observable.fromIterable() ensures that the internal Observable completes so that toList() can be used
source share