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.
Structured Concurrency & Cancellation
Launch all in one scope
Report a typo
Write a program in Kotlin
private suspend fun loadScreenInSomeScope() {
GlobalScope.launch { loadImage("image_1") }
GlobalScope.launch { loadImage("image_2") }
GlobalScope.launch { preCache("image_3") }
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.