Skip to content

Instantly share code, notes, and snippets.

@tsuijten
Last active May 19, 2020 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tsuijten/08ec47fe661faccd52da06736ddd52bf to your computer and use it in GitHub Desktop.
Save tsuijten/08ec47fe661faccd52da06736ddd52bf to your computer and use it in GitHub Desktop.
@Composable
fun MyApp() {
MaterialTheme { Counter() }
}
@Composable
fun Counter() {
val amount = +state { 0 }
Column {
Text(text = "Counter demo")
Button(text = "Add", onClick = { amount.value++ })
Button(text = "Subtract", onClick = { amount.value-- })
Text(text = "Clicks: ${amount.value}")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment