I have next use case: User comes to registration form, enters name, email and password and clicks on register button. After that system needs to check if email is taken or n
if you want both value not null
fun LiveData.combineWithNotNull(
liveData: LiveData,
block: (T, V) -> R
): LiveData {
val result = MediatorLiveData()
result.addSource(this) {
this.value?.let { first ->
liveData.value?.let { second ->
result.value = block(first, second)
}
}
}
result.addSource(liveData) {
this.value?.let { first ->
liveData.value?.let { second ->
result.value = block(first, second)
}
}
}
return result
}