Say like LiveData<List<Item> is received from remote and few of the Item's properties are calculated in the device based on some conditions.
What would be the best practices to do so. Please suggest.
Say e.g., Item class as below:
class Item{
int id
String name
float location
float distance
}
in which the id, name and location of each Item are received from remote but the distance to be calculated from location locally. How to calculate the distance and return a LiveData which can be supplied back to the View?
Appreciate your time and input.
You cant manipulate LiveData, it is an immutable data type. If you want to work with mutable live data you must use the MutableLiveData.
This document told everything about it. https://developer.android.com/topic/libraries/architecture/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