https://kotlinlang.org logo
#coroutines
Title
# coroutines
a

aerb

08/07/2019, 3:11 PM
is there a way to assert which dispatcher you’re on?
d

Dominaezzz

08/07/2019, 3:12 PM
You can check with
coroutineContext[CoroutineDispatcher]
.
a

aerb

08/07/2019, 3:13 PM
niceeee
g

gildor

08/07/2019, 3:13 PM
Check (or even assert) may be fine in some cases, bit usually better to switch on dispatcher which is needed without check
a

aerb

08/07/2019, 3:21 PM
Is there a way to get the current context without a scope? Looks like there is an internal way to do it but nothing public.
g

gildor

08/07/2019, 3:23 PM
you don’t need scope to get current context
coroutineContext property available in every suspend lambda/function
d

Dominaezzz

08/07/2019, 3:24 PM
coroutineContext
is a top level property.
g

gildor

08/07/2019, 3:24 PM
coroutineContext in scope is not the same, it’s not your runtime context, but rather a way to get new context instance to start new coroutine
a

aerb

08/07/2019, 3:28 PM
👍
4 Views