I am trying to add pagination to my `LazyColumn` u...
# compose
y
I am trying to add pagination to my
LazyColumn
using Paging3 (with its compose library). I now show the paginated list by converting the
PagingData
into a
LazyPagigItems
object. My issue is that I cannot find a way to show any state other than the success state like showing the loading indicator or showing an error when the loading of a page fails. I have done this outside Compose using RecyclerViews but I cant find anything useful for it in Compose.
Am I missing something?
m
What do you mean you cannot find a way. Have you tried observing the states,?
p
Your composable's lazy paging state object has a
loadState
with properties like
append, prepend,
refresh
that can be observed to be in Loading, Error, Refreshing, etc. Not sure on the syntax, replying here on mobile, but that's the gist of it
y
@Patrick Kellison @myanmarking Like this? 🤔
Copy code
val prependLoading = trendingGifs.loadState.prepend == LoadState.Loading
    val appendLoading = trendingGifs.loadState.append == LoadState.Loading
So if these == loading it means data is being loaded on that side? I have to just handle how to properly show it in the composables?
But what about error states
m
Not like that. Something like: if(loadstate is LoadState.Loading) ... else ...
y
Oh right
That also fixes the issue for the error thing
🤔 thanks im going to look into it now