https://kotlinlang.org logo
#compose
Title
# compose
b

Bruno_

11/04/2019, 6:31 PM
I have to display a stream of data (at least 1000 items), every
add
to
ModelList
reloads the view, no? Because of that while the items are being loaded the app lags quite a lot, do I have to implement something like a pagination myself or is there a way to optimize such thing out of the box?
l

Luca Nicoletti

11/04/2019, 6:32 PM
Right now there isn’t a component which handles this situation, from what they said, is under development
l

Leland Richardson [G]

11/04/2019, 6:32 PM
yeah right now you’d need to implement this yourself
b

Bruno_

11/04/2019, 6:32 PM
okay well will leave it as it is if that's the case
l

Luca Nicoletti

11/04/2019, 6:32 PM
What if you
.addAll()
instead of
add()
every item, is the composition re-triggered on every element?
Or just once with a big lag? 😄
b

Bruno_

11/04/2019, 6:34 PM
@Luca Nicoletti it's a rxjava flowable that collects items from ~20 web sources, already tried to batch it but it didn't help too much
l

Leland Richardson [G]

11/04/2019, 6:39 PM
regardless if you use add vs addall, it should only cause a single recomposition on the next frame. @Model observation doesn’t trigger synchronous recompositions
so it is already debounced to some degree (ie, roughly ~16ms)
but for lots of items you’ll still want to do something different
i would build something out of PagedList, not ModelList, for this use case fwiw
r

Ryan Mentley

11/04/2019, 9:19 PM
Yeah, something to handle this easily is under development