Skip to content

Instantly share code, notes, and snippets.

@thearchetypee
Created April 23, 2023 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thearchetypee/40aecea11f533bb24c203ba96ae7632a to your computer and use it in GitHub Desktop.
Save thearchetypee/40aecea11f533bb24c203ba96ae7632a to your computer and use it in GitHub Desktop.
@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