Skip to content

Instantly share code, notes, and snippets.

@satadii11
Last active November 25, 2021 08:09
Show Gist options
  • Save satadii11/214477b446252e7895c67368c194109f to your computer and use it in GitHub Desktop.
Save satadii11/214477b446252e7895c67368c194109f to your computer and use it in GitHub Desktop.
class MainViewModel : ViewModel() {
private val _count = MutableStateFlow(0)
val count get() = _count.asStateFlow()
init {
_count.value = 0
}
fun increase() {
_count.value = _count.value.inc()
}
fun decrease() {
_count.value = _count.value.dec()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment