Hi, What would be the proper way to delay a lazylist /scroll state restoration? For example with
collectAsLazyPagingItems
the state is collected in a launched effect so even if the flow is cached and available if the collect is started in a composable that is recreated there's at least a frame running with no content and the position is reset to 0. In that case I can collect earlier in a scope that is not removed as the data is cached. But what if I wanted to actually not keep the data, reload it then restore scroll. Is there some official doc / pattern for that ?
I've seen that one and that's how I understood the issue and found the "workaround" of collecting in a higher scope.
a
Albert Chang
10/07/2021, 7:15 AM
As the issue indicates scroll position shouldn't be reset any more when there's no items. If it doesn't work for you, there might be some other issue.
t
Tolriq
10/07/2021, 7:26 AM
It does not work if I log the hosted state I properly see it updated when scrolling. Remove the composable add it and collect, then I see a `lazyPagingItems.loadState`state change then instantly the state is reseted to 0 0 (Compose 1.1 alpha 5). If I skip the first state change then only after display the lazylist then the state is properly kept.
Tolriq
10/07/2021, 7:27 AM
The data is properly cached and present there's no load occuring.