Continuous
A class representing a continuous page of data.
This class is used to load data in chunks. It takes a function that loads a page of data, with the given continuation token and returns a Page with the next continuation token.
If next continuation token is null, it means there is no more data to load. The initial call to load will have a null continuation token.
Example for using with an API that uses Strings as continuation tokens:
val data = PagedData.Continuous { continuation ->
val (tracks, nextCont) = api.loadTracks(continuation)
Page(tracks, nextCont)
}Content copied to clipboard
Example for using with an API that uses Integers as continuation tokens:
val totalTracks = api.getTotalTracks()
val data = PagedData.Continuous { continuation ->
val contInt = continuation?.toIntOrNull() ?: 0
val tracks = api.loadTracks(contInt)
val nextContinuation = contInt + 10
if (nextContinuation >= totalTracks) Page(tracks, null)
else Page(tracks, nextContinuation)
}Content copied to clipboard
Parameters
load
The function to load a Page for a given continuation token
Functions
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <T : Any> PagedData<T>.toFeedData(buttons: Feed.Buttons? = null, background: ImageHolder? = null): Feed.Data<T>