Last active
January 13, 2018 20:20
-
-
Save SabagRonen/8ab1d99452e8d6e865426e21d7362198 to your computer and use it in GitHub Desktop.
Clean Architecture and Kotlin Coroutines post loading image async
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
suspend fun fetchImage(key: String, storage: Storage, imageFetcher: ImageFetcher) : Bitmap { | |
val url = async {storage.getUrlForKey(key)}.await() | |
val image = async { imageFetcher.getImageFromUrl(url) } | |
println("this might be run after the async have started") | |
return image.await() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment