Coroutines Scope Flashcards
1
Q
What is Coroutines Scope?
A
A coroutine scope keeps track of any coroutine you create using launch or async.
It basically manages the lifecycle of coroutines.
2
Q
How to cancel ongoing coroutines in a scope?
A
By calling the cancel() function on the scope object, it will cancel all ongoing coroutines.
3
Q
How to create custom scope in Coroutines?
A
It can be created by using the CoroutineScope class constructor with Job and Dispatchers like Dispatchers.Main. Ex: val scope = CoroutineScope(Job() + Dispatchers.Main)