-
Notifications
You must be signed in to change notification settings - Fork 2
Live Data
Devrath edited this page May 1, 2021
·
2 revisions
-
Live Data
is a holder of data that can be observed, Speciality of this is the unlike the regularobservable
, It islife-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
islife cycle aware
, we can avoid memory leaks and crashes caused when the activities are stopped
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 |