From 9da674852f3d6e12250fba34f475e6328399f2fe Mon Sep 17 00:00:00 2001 From: Vitali Olshevski Date: Wed, 26 Jul 2023 16:29:18 +0300 Subject: [PATCH] Remove ImmediateLaunchedEffect as it is not used anymore in the tests --- .../testutils/ImmediateLaunchedEffect.kt | 103 ------------------ 1 file changed, 103 deletions(-) delete mode 100644 test-utils/src/main/kotlin/dev/olshevski/navigation/testutils/ImmediateLaunchedEffect.kt diff --git a/test-utils/src/main/kotlin/dev/olshevski/navigation/testutils/ImmediateLaunchedEffect.kt b/test-utils/src/main/kotlin/dev/olshevski/navigation/testutils/ImmediateLaunchedEffect.kt deleted file mode 100644 index b8e5bf44..00000000 --- a/test-utils/src/main/kotlin/dev/olshevski/navigation/testutils/ImmediateLaunchedEffect.kt +++ /dev/null @@ -1,103 +0,0 @@ -@file:Suppress("unused", "TestFunctionName") - -package dev.olshevski.navigation.testutils - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.NonRestartableComposable -import androidx.compose.runtime.RememberObserver -import androidx.compose.runtime.remember -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job -import kotlinx.coroutines.cancel -import kotlinx.coroutines.launch - -private class ImmediateLaunchedEffectImpl( - private val task: suspend CoroutineScope.() -> Unit -) : RememberObserver { - private val scope = CoroutineScope(Dispatchers.Main.immediate) - private var job: Job? = null - - override fun onRemembered() { - job?.cancel("Old job was still running!") - job = scope.launch(block = task) - } - - override fun onForgotten() { - job?.cancel() - job = null - } - - override fun onAbandoned() { - job?.cancel() - job = null - } -} - -/** - * Similar to [LaunchedEffect], but uses [Dispatchers.Main.immediate] as a coroutine context. - * This cause the underlying suspend block to be executed in order with DisposableEffects. - * - * In comparison, all LaunchedEffects are executed only after all DisposableEffects and all - * SideEffects not depending on their order in composition. - */ -@Composable -@NonRestartableComposable -fun ImmediateLaunchedEffect( - key1: Any?, - block: suspend CoroutineScope.() -> Unit -) { - remember(key1) { ImmediateLaunchedEffectImpl(block) } -} - -/** - * Similar to [LaunchedEffect], but uses [Dispatchers.Main.immediate] as a coroutine context. - * This cause the underlying suspend block to be executed in order with DisposableEffects. - * - * In comparison, all LaunchedEffects are executed only after all DisposableEffects and all - * SideEffects not depending on their order in composition. - */ -@Composable -@NonRestartableComposable -fun ImmediateLaunchedEffect( - key1: Any?, - key2: Any?, - block: suspend CoroutineScope.() -> Unit -) { - remember(key1, key2) { ImmediateLaunchedEffectImpl(block) } -} - -/** - * Similar to [LaunchedEffect], but uses [Dispatchers.Main.immediate] as a coroutine context. - * This cause the underlying suspend block to be executed in order with DisposableEffects. - * - * In comparison, all LaunchedEffects are executed only after all DisposableEffects and all - * SideEffects not depending on their order in composition. - */ -@Composable -@NonRestartableComposable -fun ImmediateLaunchedEffect( - key1: Any?, - key2: Any?, - key3: Any?, - block: suspend CoroutineScope.() -> Unit -) { - remember(key1, key2, key3) { ImmediateLaunchedEffectImpl(block) } -} - -/** - * Similar to [LaunchedEffect], but uses [Dispatchers.Main.immediate] as a coroutine context. - * This cause the underlying suspend block to be executed in order with DisposableEffects. - * - * In comparison, all LaunchedEffects are executed only after all DisposableEffects and all - * SideEffects not depending on their order in composition. - */ -@Composable -@NonRestartableComposable -fun ImmediateLaunchedEffect( - vararg keys: Any?, - block: suspend CoroutineScope.() -> Unit -) { - remember(*keys) { ImmediateLaunchedEffectImpl(block) } -} \ No newline at end of file