Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Android MutableLiveData vs ObservableList?

I want to understand the difference between MutableLiveData vs ObservableList in Android ViewModel.

val questions: MutableLiveData<List<Question>> = MutableLiveData()
val options: ObservableList<Option> = ObservableArrayList()
like image 701
Yousuf Sohail Avatar asked Jan 19 '26 15:01

Yousuf Sohail


1 Answers

The main difference here is that ObservableList is designed for DataBinding while MutableLiveData for data change observation that is made from Activity or Fragment, which means that MutableLiveData takes into consideration a LifeCycle of a component and will not call it if isn't in active state.

You can use ObservableList from your code of course, but, for example, it will not hold last passed data, unlike LiveData.

like image 79
Demigod Avatar answered Jan 21 '26 04:01

Demigod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!