Thread
#compose
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    Question about
    AdapterList
    performance: with
    RecyclerView
    , when using
    DiffUtil
    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.
    EditText
    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
    AdapterList
    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
    AdapterList
    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
    DiffUtil
    ? Does this question not even make sense in the Compose world?
    v

    Vinay Gaba

    2 years ago
    Doesn’t quite answer your question but related thread for anyone interested - https://kotlinlang.slack.com/archives/CJLTWPH7S/p1580131443041400
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    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
    AdapterList
    use this same machinery for list items? And are there plans to support some sort of asynchronous processing for large lists when necessary?
    l

    Leland Richardson [G]

    2 years ago
    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
    though we should still handle the less information case well, too
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    Cool, thanks!
    coolchandrakumar

    coolchandrakumar

    2 years ago
    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]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    @coolchandrakumar the last time this was asked, the only way to do it was to listen for position changes on individual list items.