Created
November 17, 2022 21:26
-
-
Save vitorvigano/4a4344bef919d76f43943d951b8ff69e 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
val email = MutableLiveData<String>() | |
val password = MutableLiveData<String>() | |
val isEmailAndPasswordValid = MediatorLiveData<Boolean>().apply { | |
addSource(email) { validate() } | |
addSource(password) { validate() } | |
} | |
private fun validate() { | |
isEmailAndPasswordValid.value = | |
email.value.orEmpty().isNotEmpty() && password.value.orEmpty().isNotEmpty() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment