I want to preface this by saying I'm not a Kotlin developer or Android developer, so my experience is extremely limited, but I wanted to delve into some Android + Kotlin development and this was one of my issues and question that I have been wondering about for a week now.
LazyColumn
according to the docs, is said to only compose the visible items (Composable
's). If these composables do any kind of heavy lifting, when scrolling an item out of view and into view again, it seems to me that LazyColumn is defeating the entire purpose of the Compose framework?
If the framework builds up state, like for instance, manages life cycles of Composable
's then if those composables do any remember { someStateOrComputation() }
it means that the LazyColum invalidates this every time - no?
Is it possible to tell LazyColumn
not to throw away the object (and all it's state, life time management etc) when a previously displayed Compose
able goes out of view (and thus, re-use it, when it comes back into view?)
Emitting a simple text bubble and rendering some pretty trivial stuff, amounts to ~3 ms per text bubble using LazyColumn
this is outrageously bad performance, but it's fine if it happens once and then if the framework recomposes for us.
I tried replacing the LazyColumn
with a normal column and indeed - the items that get scrolled out of view, do not get reconstructed (thus, they do not invalidate ALL the state of the composable's) when scrolled back into view.
Does LazyColumn
break the entire idea behind Jetpack Compose or is there someway to tell LazyColumn to behave like Column but with the added bonus of not actually creating the lifetime management until it's seen the first time?