Created
May 1, 2023 20:08
-
-
Save saqib-github-commits/f396985bd8dedf37bdb374bd8af7f56f 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 LaunchedEffectNetworkState( | |
snackbarHostState: SnackbarHostState, | |
viewModel: LaunchedEffectNetworkStateViewModel | |
) { | |
val showNetworkUnavailable by viewModel.networkUnavailable.collectAsState() | |
if (showNetworkUnavailable) { | |
LaunchedEffect(Unit) { | |
snackbarHostState.showSnackbar("Network Unavailable") | |
} | |
} | |
Scaffold( | |
snackbarHost = { SnackbarHost(hostState = snackbarHostState) } | |
) { | |
Text(text = "Network State using LaunchedEffect") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment