Skip to content

Instantly share code, notes, and snippets.

@vitorvigano
Created November 17, 2022 21:26
Show Gist options
  • Save vitorvigano/4a4344bef919d76f43943d951b8ff69e to your computer and use it in GitHub Desktop.
Save vitorvigano/4a4344bef919d76f43943d951b8ff69e to your computer and use it in GitHub Desktop.
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