Hi devs please suggest me, I have a large number o...
# compose
t
Hi devs please suggest me, I have a large number of list which can be curated from db or network API, when displayed to user in
lazyColum or lazyRow
I want to make it selectable & unselectable (multi selection) to perform some actions on the selected items. So in order to make it selectable/unselectable? What should I use?
mutableStateListOf
? or
StateFlow<List>
?
c
Your question here seems to end with "Should I use snapshot state or flows?" Both will work. I like snapshot state, some people really like using flows throughout all of their layers. It's up to you.
t
Yeah, do they have any performance difference?
c
I don't think there's an issue.
c
Technically speaking, even when you use flows you have to use the
asState
method or whatever its called, which technically converts the flow to snapshot state anyway. so you could argue that snapshot state uses less mem because of that. Personally. i like snapshot state because its easy
Some people like flows because other libraries (like shared prefs, or database or something) exposes flows.
Flows also give you operators... like map, filter, etc. so arguably flows are more "powerful"
c
What is 'Snapshot state'?
c
snapshot state is the "type" for mutable data in compose i.e. mutableStateOf, mutableStateListOf,
collectAsState()
c
that observes and get the data whenever it changes or updates, right?
t
Thanks