louiscad
09/26/2018, 9:54 PMcurrentScope { } is deprecated, should I use its implementation, CoroutineScope(coroutineContext) instead?
I have some code relying on it:
suspend inline fun <E> ReceiveChannel<E>.doOnEach(
context: CoroutineContext = EmptyCoroutineContext,
noinline action: suspend (E) -> Unit
) = currentScope {
launch(context) { consumeEach { action(it) } }
}
that would become:
suspend inline fun <E> ReceiveChannel<E>.doOnEach(
context: CoroutineContext = EmptyCoroutineContext,
noinline action: suspend (E) -> Unit
) = CoroutineScope(coroutineContext).launch(context) { consumeEach { action(it) } }elizarov
09/27/2018, 6:36 AMGlobalScope.launch(coroutineContex) It looks more explicit to me and is slightly more efficient (one object less)..elizarov
09/27/2018, 6:37 AMlouiscad
09/27/2018, 9:41 AMGlobalScope.launch(coroutineContext + context).
Here's the gist for reference: https://gist.github.com/LouisCAD/ec559f6d62f796e9287145c4797400f7