Update Kotlin coroutines

This commit is contained in:
Kirill Kamakin
2022-05-26 10:32:55 +02:00
parent 7893c1b8bd
commit 12c5d8d5d3
2 changed files with 6 additions and 4 deletions

View File

@@ -172,7 +172,9 @@ dependencies {
testImplementation "junit:junit:4.13.2"
// https://github.com/Kotlin/kotlinx.coroutines/releases
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1"
def coroutines_version = "1.6.1"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
// https://github.com/robolectric/robolectric/releases
testImplementation "org.robolectric:robolectric:4.8.1"

View File

@@ -4,11 +4,11 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.FlowCollector
inline fun <T> Fragment.collectWhenViewResumed(
fun <T> Fragment.collectWhenViewResumed(
flow: Flow<T>,
crossinline collector: suspend (T) -> Unit,
collector: FlowCollector<T>,
) = launchWhenViewResumed { flow.collect(collector) }
fun Fragment.launchWhenViewResumed(