What I'd like to do is access data at a few different URLs, combine this data, and then work with it in my app. I'm having no trouble getting all of the data I need, but what I can't figure out is how to combine the data into a single list and know when all of the API calls are done (all of the data is in the list).
Here's the loop where I make my API calls:
for(String diningCourt: diningCourts){
menuApi.getMenu(diningCourt, date)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(responseData -> {
//I want to add responseData to a list with
//the results from the rest of the calls
});
}
What's the correct way to collect the data? I've tried using a static class variable to store the results but I only end up with data from one of the API calls. Any suggestions would be greatly appreciated.