Coverage Summary for Class: LifecycleAwareCoroutineScopeKt (com.vsevolodganin.clicktrack.utils.decompose)
Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
LifecycleAwareCoroutineScopeKt |
0%
(0/2)
|
|
0%
(0/4)
|
0%
(0/33)
|
LifecycleAwareCoroutineScopeKt$CoroutineScope$$inlined$doOnDestroy$1 |
0%
(0/2)
|
|
Total |
0%
(0/4)
|
|
0%
(0/4)
|
0%
(0/33)
|
package com.vsevolodganin.clicktrack.utils.decompose
import com.arkivanov.essenty.lifecycle.Lifecycle
import com.arkivanov.essenty.lifecycle.LifecycleOwner
import com.arkivanov.essenty.lifecycle.doOnDestroy
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlin.coroutines.CoroutineContext
fun CoroutineScope(context: CoroutineContext, lifecycle: Lifecycle): CoroutineScope {
val scope = CoroutineScope(context + SupervisorJob())
lifecycle.doOnDestroy(scope::cancel)
return scope
}
fun LifecycleOwner.coroutineScope(context: CoroutineContext = Dispatchers.Default): CoroutineScope = CoroutineScope(context, lifecycle)