In Android using Retrofit combined with RxJava I get an object Observable. Inside I have a List; inside Table I have properties containing a foreign key from the object Product. My goal is to get the ServiceProductBOM.List and for each Table with a foreign key I want to get Observable and update a field in Table with data from Product so that I have i.e. product code along with its key. At the end of the process I want to pass List to an Adapter. I would like to know how to develop the reactive part.
I tried something like this:
class ServiceProductBOM {
properties....
List<Table>
// getters and setters
}
class Table {
properties...
productForeignKey
productCode // empty to be updated later
// getters and setters
}
class Product {
properties...
key
productcode
....
// getters and setters
}
retrofitWSClient.getServiceProductBOM(...)
.flatMapIterable(bom -> bom.getTable())
.flatMap(row -> retrofitWSClient.getProduct(...)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
Once subscribed I do not know how to update the Table properties with properties from Product and keep trace to the end of process.
In the end I did something like this:
Once subscribed productObservable and completed I find updatedBom filled in with all rows updated with data from Product.