I am using LiveData
in AndroidViewModel
class where i need to wait for the response, but there are some cases where i need to check some value from local shared preference
, which won't block any thread.
For these scenarios i am not using LiveData
. This is what i am doing in my activity class
.
homeViewModel.sendTokenToServer().observe(this, isFCMSendToServer -> {
Toast.makeText(this, "FCM Token Observer called", Toast.LENGTH_SHORT).show();
});
//Without Live Data
if(homeViewModel.isUpgradeAvailable()){
displayAlertMessage();
}
I want to know if the above approach is fine, or we have to use LiveData
or some other observers for each method in ViewModel