adte
11/04/2022, 5:24 PMZach Klippenstein (he/him) [MOD]
11/04/2022, 5:59 PMadte
11/04/2022, 6:12 PMIs it cumbersome because these are nested immutable values?That's part of it yeah - the data classes are immutable and contain persistent collections, the nested functions that mutate the data need to update and return back all the state from each of them. Also, every time I mutate the points list I need to do "if (oldPoint.isSelected()) selectionBuilder.add(newPoint)" to have the new selection. If I'm not mutating some points, I still need to carry over their selection state in the new path. I'll take a look at what you mentioned. For e.g. a mouse move operation, I was thinking to store the indices of the selected points and use that to compute the new selection since the structure remains the same. Another option is to store isSelected state within the points directly, even though that is transient data.
Zach Klippenstein (he/him) [MOD]
11/04/2022, 6:33 PMZach Klippenstein (he/him) [MOD]
11/04/2022, 6:37 PMadte
11/07/2022, 2:54 PMMay I ask what your reasons for choosing to store this information in persistent/immutable data structures is?@Zach Klippenstein (he/him) [MOD] For sure! People in this thread told me Compose works better when the data is immutable (to track changes), and also I wanted to work with persistent data structures as they make it easy to implement undo (just storing each new instance). Do you think I should/could use mutable data structures for my data?
adte
11/07/2022, 2:55 PMdewildte
11/07/2022, 8:33 PMdewildte
11/07/2022, 8:34 PMdewildte
11/07/2022, 8:34 PMZach Klippenstein (he/him) [MOD]
11/07/2022, 9:51 PMadte
11/08/2022, 8:31 AMIf you’ve got really complex nested structures it may be simpler to make your objects mutable with the state holders insideAre you saying to expose MutableState<T> from my data classes? Is that a common pattern in Compose/is there overhead to having a lot of State instances?