-
-
Save saqib-github-commits/7808ba04c3f27fbf6641c6e477f5a327 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
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") | |
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun LaunchedEffectTestScreen ( | |
snackbarHostState: SnackbarHostState, | |
viewModel: LaunchedEffectTestViewModel | |
) { | |
val snackbarCount = viewModel.snackbarCount.collectAsState() | |
LaunchedEffect(snackbarCount.value) { | |
Log.d("launched-effect","displaying launched effect for count ${snackbarCount.value}") | |
try { | |
snackbarHostState.showSnackbar("LaunchedEffect snackbar", "ok") | |
} catch(e: Exception){ | |
Log.d("launched-effect","launched Effect coroutine cancelled exception $e") | |
} | |
} | |
Scaffold( | |
snackbarHost = { SnackbarHost(hostState = snackbarHostState) } | |
) { | |
Column { | |
Text(text = "LaunchedEffect Test") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment