Zach Klippenstein (he/him) [MOD]

05/04/2020, 5:56 PM
Question about
performance: with
, when using
to calculate list changes, it’s recommended to run the diff calculation on a background thread since it can be slow. This makes it tricky to use with declarative programming, because state updates to the list don’t synchronously get propagated down the tree (e.g.
in an item view causes a new list to be emitted with new text, but that text doesn’t get bound to the actual view until a few main loop iterations later, which causes state to get out of sync when typing fast). What implications does this have for
in Compose? Add/remove item animations can be done at the per-item level, which seems straightforward enough. But if the list is re-ordered, or items are inserted anywhere other than the end of the list, does
preserve composable state/groups by keying on the list items (i.e. using `key`/`Pivotal` machinery)? If it does, does it process those changes more efficiently than
? Does this question not even make sense in the Compose world?

Vinay Gaba

05/04/2020, 6:07 PM
Doesn’t quite answer your question but related thread for anyone interested -
🙏 1

Zach Klippenstein (he/him) [MOD]

05/04/2020, 6:12 PM
Interesting thread, thanks! That’s kind of what I expected from key/Pivotal. I expect inserts would be cheaper than reordering too. So I guess my main question then is: does
use this same machinery for list items? And are there plans to support some sort of asynchronous processing for large lists when necessary?

Leland Richardson [G]

05/04/2020, 11:14 PM
a lot of this stuff is still being worked out 🙂
key helps in the shuffle case a lot
but it still means that you’re going to be iterating over the full list etc.
adapterlist (or other virtualized primitives) should get you into a camp where you’re not doing an O(n) recomposition even if its shallow, and instead just doing O(screen size)
but that still means if you have no extra information that you have to run a diff of the data somewhere
ideally we give you an API to provide additional information (e.g., “5 new items inserted at X”) but we are still figuring out the best way to handle this type of thing and sort of get out of your way a bit
👍 2
though we should still handle the less information case well, too

Zach Klippenstein (he/him) [MOD]

05/05/2020, 12:09 AM
Cool, thanks!


05/06/2020, 3:52 AM
Hi, Is there a way to add scroll listener to the AdapterList to track the last item for loading more items

Zach Klippenstein (he/him) [MOD]

05/06/2020, 3:03 PM
@coolchandrakumar the last time this was asked, the only way to do it was to listen for position changes on individual list items.
👍 1