How do you pass the `CoroutineContext` when it's d...
# coroutines
p
How do you pass the
CoroutineContext
when it's defined as the receiver on a supsending function inside a class?
z
Couple things: 1.
CoroutineContext
as a receiver is odd, normally
CoroutineScope
is used as a receiver type. 2. Suspending functions shouldn’t have
CoroutineScope
receivers. If they need access to the current scope they should use the
coroutineScope
function. If you want to make it possible to add additional context, pass a
CoroutineContext
as a normal argument to your method (that’s how all the standard builders like
launch
,
async
, etc work).
p
Yep, I meant to write
CoroutineContext
, thanks.