Maxime Vince
07/25/2023, 3:01 PMRick Clephas
07/25/2023, 3:06 PMKMMViewModel
class you can access the CoroutineScope
via viewModelScope.coroutineScope
. With that you can use coroutines like you would in any other place. Hope that helps.Maxime Vince
07/25/2023, 3:48 PMRick Clephas
07/25/2023, 4:21 PMSanjayKarki
07/26/2023, 3:40 AMMaxime Vince
07/27/2023, 11:32 AMprivate fun getVlilleStations() {
_vLilleStations.update { UiState.loading() }
viewModelScope.coroutineScope.launch(<http://Dispatchers.IO|Dispatchers.IO>) {
val stations = _vLilleRepository.getVLilleStations()
val location = _locationHandler.getCurrentLocation()
val orderedList = stations
.map { it.fields }
.sortedBy {
calculationByDistance(
location.latitude,
location.longitude,
it.localisation[0],
it.localisation[1]
)
}
_vLilleStations.update {
UiState.success(MapScreenData(orderedList, location))
}
}
}
But my logcat said to me that some frames are skipped 😞Rick Clephas
07/27/2023, 7:44 PM