I have a problem with liveData. It doesn't update the fragment with the information. I think it unsubscribes from viewLifecycleOwner at some particular moment. Is there a way to track the subscription of liveData and see if it unsubscribes or not? Thank you!
Fragment
val loginResult: MutableLiveData<RequestResult<LoginResponse>> by lazy {
MutableLiveData()
}
vm.loginRequestResult.observe(viewLifecycleOwner) {
when (it) {
is RequestResult.Success -> vm.navigateToSetLocation()
is RequestResult.Error -> showErrorIncorrectEmailOrPassword()
}
}
Viewmodel:
when(response){
is RequestResult.Success -> loginRequestResult.value = response
is RequestResult.Error -> loginRequestResult.postValue(response)
}
You should move your LiveData into ViewModel