You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see in WeatherViewModel, here is the method to show weather:
fun showWeather() = viewModelScope.launch {
showLoading()
val weatherResult = weatherUseCase()
val tempUnit = getTemperatureUnit()
...
Since weatherUseCase() is a method to get weather which should be run in network thread, I wonder why don't you wrap it inside withContext(Dispatchers.IO) { }, like this:
fun showWeather() = viewModelScope.launch {
showLoading()
val weatherResult = withContext(Dispatchers.IO) { weatherUseCase() }
val tempUnit = getTemperatureUnit()
...
The text was updated successfully, but these errors were encountered:
I see in
WeatherViewModel
, here is the method to show weather:Since
weatherUseCase()
is a method to get weather which should be run in network thread, I wonder why don't you wrap it insidewithContext(Dispatchers.IO) { }
, like this:The text was updated successfully, but these errors were encountered: