Understanding LiveData made simple

--

Architecture components are now a big thing for Android developers. LiveData is one of the major components that we want to look in detail here.

In case you are are not familiar with Architecture Component, below might help.

In my blog above, it covers ViewModels and LiveData. But the LiveData is illustrated like just a normal data passing mechanism from ViewModels to the View. I have not done LiveData justice, and now it’s payback time for it.

So what’s so special about LiveData?

What is Live Data?

Formally it is defined as below

LiveData is an observable data holder class. Unlike a regular observable, LiveData is lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services. This awareness ensures LiveData only updates app component observers that are in an active lifecycle state

Well, it’s a mouth full of explanation.

--

--