Last updated 5 months ago

Listing is a structure designed to manage a list stream.

data class Listing<T>(
val pagedList: LiveData<PagedList<T>>,
val networkState: LiveData<NetworkState>,
val refresh: () -> Unit,
val refreshState: LiveData<NetworkState>,
val retry: () -> Unit

It contains basically five elements:

  1. pagedList: A changing data stream of type T represented as a LiveData of a PagedList.

    A PagedList is a List which loads its data in chunks (pages) from a DataSource.

    To display a PagedList, you must use a PagedListAdapter, which enables the binding of a PagedList to a RecyclerView.

  2. ‚ÄčnetworkState: A stream that notifies network state changes, such as when a new page started loading (so you can show a spinner in the UI).

  3. refresh: A refresh function, to refresh all data.

  4. refreshState: A stream that notifies the status of the refresh request.

  5. retry: A retry function to execute if something fails.