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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly