This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private suspend fun getWeatherDataByCity(cityName: String) { | |
CoroutineScope(Dispatchers.IO).launch { | |
val weatherData = getWeatherData(cityName) | |
withContext(Dispatchers.Main){ | |
someLiveData.value = weatherData | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private suspend fun getWeatherDataByCity(cityName: String) { | |
val deferredResult = CoroutineScope(Dispatchers.IO).async { | |
// do what you need here | |
} | |
deferredResult.await() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private suspend fun getWeatherDataByCity(cityName: String) { | |
CoroutineScope(Dispatchers.IO).async { | |
// do what you need here | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private suspend fun getWeatherDataByCity(cityName: String) { | |
CoroutineScope(Dispatchers.IO).launch { | |
// do what you need here | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private suspend fun getWeatherDataByCity(cityName: String) { | |
getWeatherData(cityName) | |
} |