rnett
11/21/2023, 10:25 PMSnapshotStateMap
in such a way as to only subscribe to updates of the key set (i.e. something is added or removed), and not value changes? Even if I have a composable that only uses SnapshotStateMap.keys
, it seems to subscribe to the whole maprnett
11/21/2023, 10:29 PMwithFrameMillis
in a LaunchedEffect
). Think particles. I then have a SubcomposeLayout
that I want to subcompose and measure each item in the map, and display it at the given offset. I'm attempting to get it to only re-measure when the items to display change, not their positions.Zach Klippenstein (he/him) [MOD]
11/21/2023, 11:08 PMZach Klippenstein (he/him) [MOD]
11/21/2023, 11:09 PMrnett
11/21/2023, 11:13 PMMap<ID, MutableState<Offset>>
shikasd
11/21/2023, 11:30 PMrnett
11/21/2023, 11:32 PMMap<ID, Unit>
for measure and Map<ID, Unit>
for placement?shikasd
11/21/2023, 11:36 PMval ids = derivedStateOf { map.keys }
val offsets = derivedStateOf { map.values }
Then you only read ids
in measure and offsets
in placement.shikasd
11/21/2023, 11:37 PMSubcomposeLayout
is the best way to display particles. You are creating a composition per each object, which might be more expensive than just recomposing layout normally.rnett
11/21/2023, 11:38 PMshikasd
11/21/2023, 11:38 PMshikasd
11/21/2023, 11:41 PMSubcomposeSlotReusePolicy
, there's a default one that just keeps a fixed number of items in reuse pool