Here's my ViewModel
class MainViewModel(repository: MainActivityRepo) : ViewModel() {
val isLoading: MutableLiveData<Boolean> = MutableLiveData()
init {
isLoading.value = false
android.os.Handler().postDelayed({
isLoading.value = true
Timber.d("isCalled")
}, 5000L)
}
}
I debugged and checked and the log is working perfectly.
The first value of boolean is set correctly, while the second is not
On background thread, you can use post value instead of set value which will solve your problem!