Last active
December 11, 2021 10:55
-
-
Save hiteshchopra11/89d39b2c83d66c1bc8d9a5960772ee37 to your computer and use it in GitHub Desktop.
Class Extending the ViewModel class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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