Answer the question
In order to leave comments, you need to log in
How to execute 2 requests sequentially in RxJava2?
There are 2 different services. The first one returns a list of cities, for the second request we pass the id of the city and get the weather.
The output is a list of cities with the weather for today.
Answer the question
In order to leave comments, you need to log in
On kotlin like this:
requestCityList()
.switchMap { cityList ->
cityList.map { city -> requestWeather(city.id) }.combineLatest { it }
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question