I am experiencing the new architectural components from google namely LiveData and ViewModel. By combining both APIs we can have the view model listening and updating the data in a reactive way.
My question is how data should be represented in a ViewModel more specifically, which way is better between having data exploded as separate fields as the following
class UserViewMode : ViewModel() {
var name = MutableLiveData<String>
vat lastName = MutableLiveData<String>
}
Or by encapsulating the data in a data holder/model class which contains both name and last name and having the view model observing this model class in a LiveData observer as the following
class UserViewMode : ViewModel() {
var user = MutableLiveData<User>
}
Thanks in advance.