Created
December 1, 2023 04:09
-
-
Save PhilipDukhov/38d17370e5156b6a6eac31f55e13da3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun SaveableLaunchedEffect( | |
key1: Any?, | |
block: suspend CoroutineScope.() -> Unit, | |
) { | |
var launched by rememberSaveable(key1) { | |
mutableStateOf(false) | |
} | |
if (!launched) { | |
LaunchedEffect(key1) { | |
block() | |
launched = true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment