Skip to content

Live Data

Devrath edited this page May 1, 2021 · 2 revisions

What is Live data

  • Live Data is a holder of data that can be observed, Speciality of this is the unlike the regular observable, It is life-cycle aware
  • Live Data forms a good communication between the data and the UI, By which change in the data, we can update the UI
  • Since the Live Data is life cycle aware, we can avoid memory leaks and crashes caused when the activities are stopped

Type of Live Data

Type About Demo classes
Live Data It can only be observed but cannot be set. It is a subclass of Object View , ViewModel
Mutable Live Data The value can be set here. It is a subclass of LiveData View , ViewModel
Mediator Live Data It is a subclass of MutableLiveData.
Here we can combite the mutable live data from two different or multiple different data sources.
Example of the scenario include when we are displaying a list of users from server and from the local database, But the data displayed in the presentation layer is a single list if users
View , ViewModel
Clone this wiki locally