I want to understand the difference between MutableLiveData vs ObservableList in Android ViewModel.
val questions: MutableLiveData<List<Question>> = MutableLiveData()
val options: ObservableList<Option> = ObservableArrayList()
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With