https://kotlinlang.org logo
#ktor
Title
# ktor
d

dorf

07/20/2020, 11:33 PM
(cross question from coroutines) Is it a typical pattern to pass around the coroutine scope (io.ktor.application.Application object) as a parameter to my suspend functions?
t

tseisel

07/21/2020, 10:03 PM
It's actually an anti pattern to have
suspend fun CoroutineScope.foo()
. An extension function on
CoroutineScope
should start coroutines in the provided scope, while a
suspend fun
should only return after all its async work is done. To access the current scope from a suspend fun, use the
coroutineScope
block.