I have a model
data class RegisterPostDataWithPwdCheck(
var phone_number: String?,
var name: String?,
var password: String?,
var secondPassword: String?)
And a ViewModel
class SignUpViewModel(application: Application) : BaseViewModel(application){
val registerPostData = MutableLiveData<RegisterPostDataWithPwdCheck>...
fun checkPassword(){}...}
I also have a View that has this code inside
viewModel.registerPostData.observe(viewLifecycleOwner, Observer {
viewModel.checkPassword()
})
In the XML there are two fields of interest
<EditText
android:id="@+id/edittext_sign_up_password"
android:text="@={view_model.registerPostData.password}" />
<EditText
android:id="@+id/edittext_sign_up_second_pw"
android:text="@={view_model.registerPostData.secondPassword}" />
What I understood so far is that the .observe
will be called only when the entire RegisterPostDataWithPwdCheck
object changes and I don't want that. I want it to be triggered when any of the parameters changes so I can call the fun checkPassword(){}
in order to see if the two fields match. Is this possible?