ste
04/29/2022, 11:10 AM@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@OptIn(InternalComposeApi::class)
@Composable
@NonRestartableComposable
fun relaunchableEffect(
key1: Any?,
block: suspend CoroutineScope.() -> Unit
): () -> Unit {
val applyContext = currentComposer.applyCoroutineContext
val launchedEffect = remember(key1) { LaunchedEffectImpl(applyContext, block) }
return launchedEffect::onRemembered
}
Zach Klippenstein (he/him) [MOD]
05/17/2022, 11:12 PMval scope = rememberCoroutineScope()
Button(onClick = { scope.launch { someSuspendFun() } })
ste
05/18/2022, 10:21 AMsomeSuspendFun
approach forces the programmer to handle cancellation manually, so "exploiting" LaunchedEffect
looked like the simplest option as it works out of the boxZach Klippenstein (he/him) [MOD]
05/18/2022, 2:40 PM