Loading and displaying paged data
There are essential steps to consider when loading and displaying paged data. In addition, the Paging library provides tremendous advantages for loading and displaying large, paged datasets. A few steps you must have in mind is ensuring you first define a data source, your Paging Source set up streams if needed, and more.
In this recipe, we will look at how loading and displaying paged data works.
How to do it…
You need to have completed the Implementing the Jetpack Paging library recipe to be able to follow along with the explanation of this recipe:
- You might have noticed in our first recipe that we override
load()
, a method that we use to indicate how we retrieve the paged data from our corresponding data source:override suspend fun load(params: LoadParams<Int>): LoadResult<Int, NewsArticle> {
return try {
val page = params.key ?: 1
...