Inside main activity, i cannot call getValue() on a MutableLiveData attribute of a ViewModel; however, i can inside the ViewModel class. What is the reason for this?
Example code: Main Activity -
noodleViewModel = ViewModelProviders.of(this).get(NoodleViewModel.class);
noodleViewModel.indexOfItemSelected.observe(this, index ->
{
Toast.makeText(this, String.format("This is the index: %d", index.intValue()), Toast.LENGTH_SHORT).show();
);
Inside ViewModel class -
public int getPosition() {
return indexOfItemSelected.getValue();
}