This is a general design question and I'm just trying to wrap my head around the best way to go about it.
Let's say I have a local database. I have a use case to retrieve some information from that database and build a model out of it. This model has things like a minimum, a maximum, and user selected values. I then give this model to my view model, which in turn puts it in a live data object and tells me a fragment to update the UI.
My fragment, then takes this live data object and builds a form with the values, including min and max values, and user entered values. The user then has the ability to change multiple fields (through pickers, date picker), before they click on a save button to save the entire form.
I'm wondering what is the best way to go about updating the data as the user is filling in the form. Originally I thought that as each field is entered, I should be updating my live data object, so that if the screen were to be destroyed or rotated, my UI would be rebuilt off my updated live data object.
However, I've been told that instead I should just keep the values in variables until the user clicks the save button. Then I should update the live data object as well as store that data in the database. In this case, I guess I'd use SaveInstanceState to retain the values that the user had entered.
I know there probably isn't a definite answer, but I'm looking for what is the best practice for a pattern like this. Let me know if you need more information. I've seen lots of MVVM examples with LiveData when data changes in the backend, but not many when there is user input to work with.
Any suggestion will be appreciated. Thanks.