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

Lukas Lechner

08/23/2022, 8:54 AM
How can I print out the coroutine context in which a flow operator is running?
s

Sam

08/23/2022, 8:54 AM
println(currentCoroutineContext())
?
l

Lukas Lechner

08/23/2022, 8:55 AM
awesome! Thank you!
Follow up question - How did you know about this? Is it something you discovered by yourself (if so, how?) or did you simply read it somewhere in the docs?
s

Sam

08/23/2022, 9:01 AM
I tend to read source code and docs a lot while I’m working, especially for interesting stuff like coroutines. I know I’ve used
currentCoroutineContext()
at least once before in real code when writing a caching library. Couldn’t tell you exactly where or when I first learned of its existence, though.
4 Views