Jonathan
06/10/2025, 10:48 PMdata class
) that represents an entire screen. My screen contains a LazyColumn
of that can/will be updated frequently (several times a second). This list is currently backed by List<String>
that is a property of my UI state holder class that I update using .copy(feed = …)
.
I don’t believe this to be very optimal and would cause excess recompositions because my UI state holder is changing frequently, even though its just the list property changing. I think using mutableStateListOf<String>(...)
would be the better choice. What I’m unsure of is the best way to present this new state to my UI. Is it optimal to nest compose state objects such that I’d just replace the List<String>
type with SnapshotStateList<String>
?
Furthermore, this type is mutable and I was under the impression that exposing mutable state outside of it’s owner/manager is bad practice. I don’t see a StateList<State>
that I could use to expose an immutable reference to state like the singular State<T>
observer.
I could always keep the mutable list state separate from the overall screen UI state holder but I’d like to keep all screen UI state together if possible.Jonathan
06/11/2025, 12:01 AMPablichjenkov
06/11/2025, 12:58 AM