Описание тега android-livedata
LiveData is part of new Android Architecture Components
LiveData used as holder to put values and allow it to be observed. It also respects lifecycle of the app components viz. onCreate(), onDestroy() etc.
It is part of Android Architecture Lifecycle library which comes with Lifecycles
, LiveData
, and ViewModel
.
LiveData is usually used with ViewModel
to bind it with view and observe the changes accordingly. It is active when one or more active Observer
s are subscribed and is in-active when they are no active observers.(Active Observers means observers [Activity, Fragment] which are in STARTED
or RESUMED
state. As it is Lifecycle aware we can share it among multiple activities and fragments etc.
Diagram explains its place in Android Architecture Components. https://stackru.com/images/c26ac5aa041f2e7171d828aac8d661a24e64a9f0.png
As shown in diagram, It gets data from repository and can be observed in Activity or Fragment via ViewModel
You can find more about it below