If we scope LiveData
to the lifecycle of a fragment
by passing this
to the observe
method, the fragment
doesn't get immediate updates if it is only detached from the activity, but not removed, because only the view
is destroyed, not the fragment
instance itself.
Instead, we can scope LiveData
to the lifecycle of the view
of the fragment, by calling observe
in onActivityCreated
and passing getViewLifecycleOwner()
rather than this
.
Is there any reason to not scope the LiveData
to the fragment
's view
?