Skip to content

Instantly share code, notes, and snippets.

@putrarifin
Created December 4, 2020 17:41
Show Gist options
  • Save putrarifin/ca4669ad3a701d50f0e4300159949fd4 to your computer and use it in GitHub Desktop.
Save putrarifin/ca4669ad3a701d50f0e4300159949fd4 to your computer and use it in GitHub Desktop.
@ExperimentalCoroutinesApi
class MainViewModel : ViewModel() {
private val _countState = MutableStateFlow(0)
val countState: StateFlow<Int> = _countState
fun incrementCount() {
_countState.value++
}
fun decrementCount() {
_countState.value--
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment