Jorge Domínguez
08/01/2022, 8:01 PMBradleycorn
08/01/2022, 9:00 PMInitially I was constructing the object in the Compose callback for the Create button, but I believe that’s something the UI shouldn’t be doingThat is correct. I would think of it this way … when the user clicks the button, the UI should not have to know “oh, they clicked the button, the app is going to need all this data and use it to create a new object X, so I’ll collect it and create the object” … The UI shouldn’t know any of that. The UI shouldn’t even know what the button is for or that there is any other data at all. All the UI should know is … “the user clicked the button, so I’ll inform the app (i.e. the ViewModel) that it was clicked, and the app can do whatever it wants in response”. Then, the responsibility falls on the ViewModel to gather up all the relevant data and do something with it (probably pass it along to another layer/class that contains the business logic to use the data in a meaningful way) when it’s “onButtonClicked” function is called.
Jorge Domínguez
08/01/2022, 10:27 PM