When creating an edit screen for an object, would ...
# compose
a
When creating an edit screen for an object, would it be best practice to have each modifiable property in it's own
by remember {mutableStateof(")}
and when the user clicks save, all the fields are passed into an object which is saved back into the database. Or would it be better to simply edit the object in the viewmodel on every single change that occurs to it and have the UI observe it?
s
It depends on your requirements. If you want to keep the edited fields when the user goes back or directly closes the application, you can pass the edit events to the view model and edit the object in the database or whatever. If you want to discard changes if the user goes back without saving, you should probably create a state holder and remember it or keep it in your viewmodel and update the object in the database when the user hits save.