KotlinLeaner
01/26/2023, 12:10 PMscope
i.e.
private val scope = CoroutineScope(SupervisorJob() + <http://Dispatchers.IO|Dispatchers.IO>)
or
private val scope = CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO> + SupervisorJob())
?KotlinLeaner
01/26/2023, 12:11 PMJoffrey
01/26/2023, 12:12 PMJoffrey
01/26/2023, 12:12 PMKotlinLeaner
01/26/2023, 12:13 PMKotlinLeaner
01/26/2023, 12:13 PMJoffrey
01/26/2023, 12:14 PMprivate val scope = CoroutineScope(someOtherContext + <http://Dispatchers.IO|Dispatchers.IO>)
vs
private val scope = CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO> + someOtherContext)
In the first case, if the externally provided context already has a dispatcher, it will be overridden, so IO
is guaranteed in this scope.
In the second case, the externally provided dispatcher (if present) will take precedence over the explicit one, so IO
would be like a default.KotlinLeaner
01/26/2023, 12:17 PM