Launch all in one scope

Report a typo

Look at this code, which tries to load some images for a screen but does that in the wrong scope, so when the user leaves, the images keep loading. Change the code to make it work in a single scope.

Write a program in Kotlin
private suspend fun loadScreenInSomeScope() {
GlobalScope.launch { loadImage("image_1") }
GlobalScope.launch { loadImage("image_2") }
GlobalScope.launch { preCache("image_3") }
}
___

Create a free account to access the full topic