I want to call a function in a ViewModel which returns nothing when a value is different from 0.
Here is the code I have so far, but it doesn't get triggered.
val categoryId = MutableLiveData<Int>()
val waitToCallApi: LiveData<Unit> = Transformations.map(categoryId) {
if(it != 0) {
getData()
} else {
// nothing
}
}
I need this because categoryId gets its value after the init method call.