Created
April 23, 2023 08:55
-
-
Save thearchetypee/40aecea11f533bb24c203ba96ae7632a 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 MyComponent() { | |
val count = remember { mutableStateOf(0) } | |
val countFlow = snapshotFlow { count.value } | |
LaunchedEffect(countFlow) { | |
countFlow.collect { value -> | |
// Handle the new value | |
} | |
} | |
Button(onClick = { count.value++ }) { | |
Text("Clicked ${count.value} times") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment