-
-
Save nsadisha/5d019a9d29d8ac935af36f169bcdf8cf to your computer and use it in GitHub Desktop.
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
package com.nsadisha.mvvmtest_2.viewModel | |
import androidx.lifecycle.LiveData | |
import androidx.lifecycle.MutableLiveData | |
import androidx.lifecycle.ViewModel | |
import com.nsadisha.mvvmtest_2.model.Counter | |
class FirstViewModel: ViewModel() { | |
private var _data = MutableLiveData<Counter>().apply { | |
value = Counter(0) | |
} | |
val data: LiveData<Counter> = _data | |
fun increase(){ | |
_data.value = _data.value.apply { | |
this?.increment() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment