I have a list of objects: ArrayList<T> arrayList; and on every object of the list there is an Id: T.getId() whom I need for making a request. As a response another list of objects is fetched: ArrayList<E> anotherList
I want to make multiple calls based on the id: T.getId() and on every response I want to merge that Object: T with the response: ArrayList<E> anotherList on a hashmap: Hashmap<T, ArrayList<E> anotherList> and return the value after all requests has been finished. Is there a way i can achieve this using rxJava?:
//For every `T.getId()`, fetch `ArrayList<E> anotherList`
for(int i=0; i<arrayList.size(); i++){
T object = arrayList.get(i);
fetchData(T.getId());
}
on every onNext() merge(hashmap.put()) T with response ArrayList<E> anotherList on Hashmap<T, ArrayList<E> anotherList>. After all requests finished return final hashmap containing those pairs:
retrofit.fetchData(T.getId())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMap(...)
.merge(...)
.subscribeWith(...)
Is there a way i can achieve this ?