Member-only story
Pagination Just Like Good Old Days
Pagination With Room Database and Jetpack Compose — Part 2
Implementation of Paging Logic without any Libraries
Overview
This is the second part of a series exploring the implementation of pagination using the Room database as the data source and Jetpack Compose for building the UI. I’ll leave a link to the GitHub sample project of what we’ll discuss here for better understanding, feel free to play around.
Before we dive into the existing stuff, let me briefly recap Part One in case you haven’t read it yet. In part one, we used the Paging3 library that is supported by the Room and Compose out of the box. We also built the application’s UI, defined entities, and DAOs needed for database configuration in part one, so I would highly recommend reading it first.
Now, let’s get into the good stuff, paging library in part one took care of two core tasks:
- Fetch data from the Room database in chunks thus making it performance effective for large datasets.
- Detect the scroll threshold to trigger the fetch of the next batch of items.
In this part of the series, we’ll explore how to implement both of the tasks by writing our core logic. But…