Skip to content

Instantly share code, notes, and snippets.

@hiteshchopra11
Last active December 11, 2021 10: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 hiteshchopra11/89d39b2c83d66c1bc8d9a5960772ee37 to your computer and use it in GitHub Desktop.
Save hiteshchopra11/89d39b2c83d66c1bc8d9a5960772ee37 to your computer and use it in GitHub Desktop.
Class Extending the ViewModel class
class MainActivityViewModel : ViewModel() {
private val _counterLiveData = MutableLiveData(0)
val counterLiveData: LiveData<Int> = _counterLiveData
fun incrementByOne() {
_counterLiveData.value = _counterLiveData.value?.plus(1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment