Skip to content

Paging Library

Perhaps not a very popular opinion, but there's no worse library from Google, among current ones. This is a great example of a situation when you needed to stop in time.

Google decided to chase all the rabbits in the world. In an attempt to make abstractions over all possible ways of pagination, they seem to have lost any sense of using this library. And by the third version it still hasn't gotten much better. Soon pagination libraries will have their own pagination.

From an architectural point of view, this is some kind of horror. Flow stretches from data layer to UI, and UI directly controls it, tells what to load. Bypassing all your screen states, bypassing all layers of your architecture, just a data stream.

Accordingly, if you need to somehow prepare data from loaded pages for presentation, enrich them with some additional fields, change them on the fly, then you're doomed to build all sorts of combines over flow. Well, there are no more options for working with flow, but I initially don't really understand why the UI layer needs flow, and not just state with a list of models.

I want to nitpick even about naming, because in what universe is LazyPagingItems not some collection, but an object from which you can get state or retry loading?

Clear the list when the pager changes - no way, there are no such methods. Remember the page that's shown to the user to start loading from it on restart - no way, there are no such callbacks. Refresh the page - only from a composable function, you can't from logic. Some cachedIn for flow, some refresh keys - all this seems to solve problems I didn't have, if I just had a list in the viewmodel state.

Are my use cases so complex? I fully admit that I'm doing something wrong, but no matter how many times I tried to attach Google's paging - it always turned out some crap, if it's not the simplest case with loading only down, where you can ignore the state on restart. And even this case is solved without paging library much more flexibly. Absurd. Why is it needed?

So this time I tried to figure it out, didn't understand why I need it, and wrote my own.