Hi! I have a pretty basic application. Basically i...
# compose
n
Hi! I have a pretty basic application. Basically it shuffles a list of ~150 strings. I’m concerned with performance. Recompose alone takes ~50ms each time. Full rendering is ~100-120ms / per shuffle. I realize this is a worst case for Compose (fully reshuffling 150 elements). Anything ideas how to improve performance? Code https://gist.github.com/tonsky/bca64aeb0c0e79151c39dd0e5a508d22
l
Wait for a recycler component 😄
😄 1
n
Scroll performance is not the issue. I guess what I am asking is if there’s a way to say to composer: this content is completely new, do not waste your time trying to match it up with what was there before?
l
Oh I see, like an invalidate on a view
You just want to force a re-rendering as you know the entire content changed
n
kinda
z
m
Hey. Can you try to wrap Line invocation in foreach with key(it) ?
It will, as mentioned above in docs, add a pivotal memorization param so runtime will know that they're the same composables, just reordered
n
@Zsolt yes it makes it slightly slower
@matvei I’m not sure what it wants from me
wrapping in Key (capital) makes it slightly slower, ~on par with
@Pivotal
m
Yep, it's capital K in dev03, sorry.
wrapping in Key (capital) makes it slightly slower
Oh, it suppose to be the opposite. Can you file a bug please?
n
No, I can see why it is that way. It’s faster to create new components than trying to find old ones, because list is quite big (150 elements) and components are simple
it’s the absolute number that worries me. 120ms is a lot of time for such a simple component. Even on a first render
I guess that would be a way to turn off composer:
Copy code
Key(Math.random()) {
  lines.value.forEach {
    Line(it)
  }
}
m
I'd assume 150 is the number we still want to be able provide good experience with. What's more important is that we shouldn't make it noticeably worth, as one of the primary
Key
functions is also correctness (proper invocation of
onCommit/onDispose
) . As for first compositions / recompositions, we still have work to do in that areas, but there has been progress already and more to go.
a
I am making infinite scrolling view. After making to the end of verticalScroller. I am calling api to load more data and store it in a local db. I am observing the local db and as change happen i recieved a new list of data(with old data also). Now the problem is that scroller is recomposing the whole view. I only want the data to load with new ids. Is using
Key
or
Pivotal
helps ?