Rafs
11/27/2020, 5:43 PMloadFavoriteStations()
returns a Flow<List<T>>
The first map
gives me a List<T>
that I need to map hence the nested map
calls.allan.conda
11/27/2020, 5:45 PMRafs
11/27/2020, 5:46 PMallan.conda
11/27/2020, 5:52 PMallan.conda
11/27/2020, 5:53 PMallan.conda
11/27/2020, 5:58 PMprivate fun loadFavoriteWeather() = viewModelScope.launch(dispatcher) {
val favoriteStations = weatherRepository.loadFavoriteStations()
if (favoriteStations == null) { // more fine-grained error handling
Log.e ("Failed to load stations")
}
val windInfo = favoriteStations.map { weatherRepository.loadWindInfo(it.name) }
if (windInfo == null) {
Log.e ("Failed to wind info")
}
}
Dominaezzz
11/27/2020, 7:38 PMflatMap
and onEach
.gildor
11/28/2020, 12:48 AMradityagumay
12/05/2020, 12:06 PMflatMap
can be used