# PagingSource

Artifact: [androidx.paging:paging-common](https://developer.android.com/jetpack/androidx/releases/paging) [View Source](https://cs.android.com/search?q=file:androidx/paging/PagingSource.kt+class:androidx.paging.PagingSource) Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  abstract class PagingSource<Key : Any, Value : Any>
  ```
Known direct subclasses [ListenableFuturePagingSource](https://developer.android.com/reference/kotlin/androidx/paging/ListenableFuturePagingSource), [RxPagingSource](https://developer.android.com/reference/kotlin/androidx/paging/rxjava2/RxPagingSource), [RxPagingSource](https://developer.android.com/reference/kotlin/androidx/paging/rxjava3/RxPagingSource)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/paging/ListenableFuturePagingSource` | `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html`-based compatibility wrapper around `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`'s suspending APIs. |
| `https://developer.android.com/reference/kotlin/androidx/paging/rxjava2/RxPagingSource` | Rx-based compatibility wrapper around `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`'s suspending APIs. |
| `https://developer.android.com/reference/kotlin/androidx/paging/rxjava3/RxPagingSource` | Rx-based compatibility wrapper around `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`'s suspending APIs. |

*** ** * ** ***

Base class for an abstraction of pageable static data from some source, where loading pages of data is typically an expensive operation. Some examples of common `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`s might be from network or from a database.

An instance of a `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` is used to load pages of data for an instance of `https://developer.android.com/reference/kotlin/androidx/paging/PagingData`.

A `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` can grow as it loads more data, but the data loaded cannot be updated. If the underlying data set is modified, a new `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` / `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` pair must be created to represent an updated snapshot of the data.

### Loading Pages

`https://developer.android.com/reference/kotlin/androidx/paging/PagingData` queries data from its `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` in response to loading hints generated as the user scrolls in a `RecyclerView`.

To control how and when a `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` queries data from its `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`, see `https://developer.android.com/reference/kotlin/androidx/paging/PagingConfig`, which defines behavior such as `https://developer.android.com/reference/kotlin/androidx/paging/PagingConfig#pageSize()` and `https://developer.android.com/reference/kotlin/androidx/paging/PagingConfig#prefetchDistance()`.

### Updating Data

A `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` / `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` pair is a snapshot of the data set. A new `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` / `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` must be created if an update occurs, such as a reorder, insert, delete, or content update occurs. A `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` must detect that it cannot continue loading its snapshot (for instance, when Database query notices a table being invalidated), and call `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#invalidate()`. Then a new `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` / `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` pair would be created to represent data from the new state of the database query.

### Presenting Data to UI

To present data loaded by a `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` to a `RecyclerView`, create an instance of `https://developer.android.com/reference/kotlin/androidx/paging/Pager`, which provides a stream of `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` that you may collect from and submit to a androidx.paging.PagingDataAdapter.

```kotlin
import androidx.paging.PagingSource
import androidx.paging.PagingSource.LoadResult
import androidx.paging.PagingState

/**
 * Sample page-keyed PagingSource, which uses Int page number to load pages.
 *
 * Loads Items from network requests via Retrofit to a backend service.
 *
 * Note that the key type is Int, since we're using page number to load a page.
 */
class MyPagingSource(val myBackend: MyBackendService) : PagingSource<Int, Item>() {
    override suspend fun load(params: LoadParams<Int>): LoadResult<Int, Item> {

        // Retrofit calls that return the body type throw either IOException for network
        // failures, or HttpException for any non-2xx HTTP status codes. This code reports all
        // errors to the UI, but you can inspect/wrap the exceptions to provide more context.
        return try {
            // Key may be null during a refresh, if no explicit key is passed into Pager
            // construction. Use 0 as default, because our API is indexed started at index 0
            val pageNumber = params.key ?: 0

            // Suspending network load via Retrofit. This doesn't need to be wrapped in a
            // withContext(Dispatcher.IO) { ... } block since Retrofit's Coroutine
            // CallAdapter dispatches on a worker thread.
            val response = myBackend.searchItems(pageNumber)

            // Since 0 is the lowest page number, return null to signify no more pages should
            // be loaded before it.
            val prevKey = if (pageNumber > 0) pageNumber - 1 else null

            // This API defines that it's out of data when a page returns empty. When out of
            // data, we return `null` to signify no more pages should be loaded
            val nextKey = if (response.items.isNotEmpty()) pageNumber + 1 else null
            LoadResult.Page(data = response.items, prevKey = prevKey, nextKey = nextKey)
        } catch (e: IOException) {
            LoadResult.Error(e)
        } catch (e: HttpException) {
            LoadResult.Error(e)
        }
    }

    override fun getRefreshKey(state: PagingState<Int, Item>): Int? {
        return state.anchorPosition?.let {
            state.closestPageToPosition(it)?.prevKey?.plus(1)
                ?: state.closestPageToPosition(it)?.nextKey?.minus(1)
        }
    }
}
```

```kotlin
import androidx.paging.PagingSource
import androidx.paging.PagingSource.LoadResult
import androidx.paging.PagingState

/**
 * Sample item-keyed [PagingSource], which uses String tokens to load pages.
 *
 * Loads Items from network requests via Retrofit to a backend service.
 */
class MyPagingSource(val myBackend: MyBackendService) : PagingSource<String, Item>() {
    override suspend fun load(params: LoadParams<String>): LoadResult<String, Item> {
        // Retrofit calls that return the body type throw either IOException for network
        // failures, or HttpException for any non-2xx HTTP status codes. This code reports all
        // errors to the UI, but you can inspect/wrap the exceptions to provide more context.
        return try {
            // Suspending network load via Retrofit. This doesn't need to be wrapped in a
            // withContext(Dispatcher.IO) { ... } block since Retrofit's Coroutine
            // CallAdapter dispatches on a worker thread.
            val response = myBackend.searchItems(params.key)
            LoadResult.Page(
                data = response.items,
                prevKey = response.prev,
                nextKey = response.next,
            )
        } catch (e: IOException) {
            LoadResult.Error(e)
        } catch (e: HttpException) {
            LoadResult.Error(e)
        }
    }

    override fun getRefreshKey(state: PagingState<String, Item>): String? {
        return state.anchorPosition?.let { state.closestItemToPosition(it)?.id }
    }
}
```

| Parameters |
|---|---|
| `<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of key which define what data to load. E.g. `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` to represent either a page number or item position, or `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` if your network uses Strings as next tokens returned with each response. |
| `<Value : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of data loaded in by this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`. E.g., the type of data that will be passed to a androidx.paging.PagingDataAdapter to be displayed in a `RecyclerView`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/paging/Pager` |   |

## Summary

| ### Nested types |
|---|
| `sealed class https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadParams<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` Params for a load request on a `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` from `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)`. |
| `class https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadParams.Append<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> : https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadParams<Key>` Params to load a page of data from a `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` via `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` to be appended to the end of the list. |
| `class https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadParams.Prepend<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> : https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadParams<Key>` Params to load a page of data from a `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` via `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` to be prepended to the start of the list. |
| `class https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadParams.Refresh<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> : https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadParams<Key>` Params for an initial load request on a `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` from `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` or a refresh triggered by `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#invalidate()`. |
| `sealed class https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadResult<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, Value : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` Result of a load request from `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)`. |
| `data class https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadResult.Error<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, Value : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> : https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadResult<Key, Value>` Error result object for `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)`. |
| `class https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadResult.Invalid<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, Value : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> : https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadResult<Key, Value>` Invalid result object for `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` |
| `data class https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, Value : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> : https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadResult<Key, Value>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-iterable/index.html<Value>` Success result object for `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)`. |

| ### Public constructors |
|---|---|
| `<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, Value : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#PagingSource()()` | Cmn |

| ### Public functions |
|---|---|---|
| `abstract Key?` | `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#getRefreshKey(androidx.paging.PagingState)(state: https://developer.android.com/reference/kotlin/androidx/paging/PagingState<Key, Value>)` Provide a `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` used for the initial `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` for the next `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` due to invalidation of this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#invalidate()()` Signal the `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` to stop loading. | Cmn |
| `abstract suspend https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadResult<Key, Value>` | `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)(params: https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadParams<Key>)` Loading API for `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#registerInvalidatedCallback(kotlin.Function0)(onInvalidatedCallback: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Add a callback to invoke when the `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` is first invalidated. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#unregisterInvalidatedCallback(kotlin.Function0)(onInvalidatedCallback: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Remove a previously added invalidate callback. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#invalid()` Whether this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` has been invalidated, which should happen when the data this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` represents changes since it was first instantiated. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#jumpingSupported()` `true` if this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` supports jumping, `false` otherwise. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#keyReuseSupported()` `true` if this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` expects to re-use keys to load distinct pages without a call to `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#invalidate()`, `false` otherwise. | Cmn |

## Public constructors

### PagingSource

Cmn

```
<Key : Any, Value : Any> PagingSource()
```

| Parameters |
|---|---|
| `<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of key which define what data to load. E.g. `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` to represent either a page number or item position, or `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` if your network uses Strings as next tokens returned with each response. |
| `<Value : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of data loaded in by this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`. E.g., the type of data that will be passed to a androidx.paging.PagingDataAdapter to be displayed in a `RecyclerView`. |

## Public functions

### getRefreshKey

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
abstract fun getRefreshKey(state: PagingState<Key, Value>): Key?
```

Provide a `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` used for the initial `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` for the next `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` due to invalidation of this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`. The `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` is provided to `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` via `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadParams#key()`.

The `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` returned by this method should cause `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` to load enough items to fill the viewport *around* the last accessed position, allowing the next generation to transparently animate in. The last accessed position can be retrieved via `https://developer.android.com/reference/kotlin/androidx/paging/PagingState#anchorPosition()`, which is typically the *top-most* or *bottom-most* item in the viewport due to access being triggered by binding items as they scroll into view.

For example, if items are loaded based on integer position keys, you can return `( (state.anchorPosition ?: 0) - state.config.initialLoadSize / 2).coerceAtLeast(0)`.

Alternately, if items contain a key used to load, get the key from the item in the page at index `https://developer.android.com/reference/kotlin/androidx/paging/PagingState#anchorPosition()` then try to center it based on `state.config.initialLoadSize`.

| Parameters |
|---|---|
| `state: https://developer.android.com/reference/kotlin/androidx/paging/PagingState<Key, Value>` | `https://developer.android.com/reference/kotlin/androidx/paging/PagingState` of the currently fetched data, which includes the most recently accessed position in the list via `https://developer.android.com/reference/kotlin/androidx/paging/PagingState#anchorPosition()`. |

| Returns |
|---|---|
| `Key?` | `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` passed to `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` after invalidation used for initial load of the next generation. The `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` returned by `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#getRefreshKey(androidx.paging.PagingState)` should load pages centered around user's current viewport. If the correct `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` cannot be determined, `null` can be returned to allow `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` decide what default key to use. |

### invalidate

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
fun invalidate(): Unit
```

Signal the `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` to stop loading.

This method is idempotent. i.e., If `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#invalidate()` has already been called, subsequent calls to this method should have no effect.

### load

Cmn

```
abstract suspend fun load(params: PagingSource.LoadParams<Key>): PagingSource.LoadResult<Key, Value>
```

Loading API for `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`.

Implement this method to trigger your async load (e.g. from database or network).

### registerInvalidatedCallback

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
fun registerInvalidatedCallback(onInvalidatedCallback: () -> Unit): Unit
```

Add a callback to invoke when the `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` is first invalidated.

Once invalidated, a `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` will not become valid again.

A `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` will only invoke its callbacks once - the first time `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#invalidate()` is called, on that thread.

If this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` is already invalid, the provided `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#registerInvalidatedCallback(kotlin.Function0)` will be triggered immediately.

| Parameters |
|---|---|
| `onInvalidatedCallback: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The callback that will be invoked on thread that invalidates the `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`. |

### unregisterInvalidatedCallback

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
fun unregisterInvalidatedCallback(onInvalidatedCallback: () -> Unit): Unit
```

Remove a previously added invalidate callback.

| Parameters |
|---|---|
| `onInvalidatedCallback: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The previously added callback. |

## Public properties

### invalid

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
val invalid: Boolean
```

Whether this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` has been invalidated, which should happen when the data this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` represents changes since it was first instantiated.

### jumpingSupported

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
open val jumpingSupported: Boolean
```

`true` if this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` supports jumping, `false` otherwise.

Override this to `true` if pseudo-fast scrolling via jumps is supported.

A jump occurs when a `RecyclerView` scrolls through a number of placeholders defined by `https://developer.android.com/reference/kotlin/androidx/paging/PagingConfig#jumpThreshold()` and triggers a load with `https://developer.android.com/reference/kotlin/androidx/paging/LoadType#REFRESH`.

`https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`s that support jumps should override `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#getRefreshKey(androidx.paging.PagingState)` to return a `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` that would load data fulfilling the viewport given a user's current `https://developer.android.com/reference/kotlin/androidx/paging/PagingState#anchorPosition()`.

To support jumping, the `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page` returned from this PagingSource must implement `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page#itemsBefore()` and `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page#itemsAfter()` to notify Paging the boundaries within which it can jump.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/paging/PagingConfig#jumpThreshold()` |   |

### keyReuseSupported

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

```
open val keyReuseSupported: Boolean
```

`true` if this `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` expects to re-use keys to load distinct pages without a call to `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#invalidate()`, `false` otherwise.