I have the List of SourceObjects and I need to convert it to the List of ResultObjects.
I can fetch one object to another using method of ResultObject:
c
If you want to maintain the Lists emitted by the source Observable but convert the contents, i.e. Observable to >
Observable, you can do something like this:>
Observable> source = ...
source.flatMap(list ->
Observable.fromIterable(list)
.map(item -> new ResultsObject().convertFromSource(item))
.toList()
.toObservable() // Required for RxJava 2.x
)
.subscribe(resultsList -> ...);
This ensures a couple of things:
Lists emitted by the Observable is maintained. i.e. if the source emits 3 lists, there will be 3 transformed lists on the other endObservable.fromIterable() will ensure the inner Observable terminates so that toList() can be used