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.

This task uses dependencies that may not be available in your local IDE. As a result, you may see compilation errors or unresolved references when running the code locally. This does not affect solution validation when you submit your solution to Hyperskill.

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