This Google sample calls observe on LiveData in a fragment and passes getActivity() as the LifecycleOwner.
mSeekBarViewModel.seekbarValue.observe(getActivity(), new Observer<Integer>() {
@Override
public void onChanged(@Nullable Integer value) {
if (value != null) {
mSeekBar.setProgress(value);
}
}
});
I can't wrap my head around any reasons to do that. I only want updates as long as the fragment is active, so why not scope it to the fragment?
Are there any reasons to ever NOT scope it to the fragment?