# PageKeyedDataSource.LoadCallback

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

*** ** * ** ***


```
public abstract class PageKeyedDataSource.LoadCallback<Key extends Object, Value extends Object>
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
> PageKeyedDataSource is deprecated and has been replaced by PagingSource, use this instead:
>
> ```
> PagingSource<Key, Value>
> ```

Callback for `https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadBefore(androidx.paging.PageKeyedDataSource.LoadParams)` and `https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadAfter(androidx.paging.PageKeyedDataSource.LoadParams)` to return data.

A callback can be called only once, and will throw if called again.

It is always valid for a DataSource loading method that takes a callback to stash the callback and call it later. This enables DataSources to be fully asynchronous, and to handle temporary, recoverable error states (such as a network error that can be retried).

| Parameters |
|---|---|
| `<Key extends https://developer.android.com/reference/java/lang/Object.html>` | Type of data used to query pages. |
| `<Value extends https://developer.android.com/reference/java/lang/Object.html>` | Type of items being loaded. |

## Summary

| ### Public constructors |
|---|
| `<Key extends https://developer.android.com/reference/java/lang/Object.html, Value extends https://developer.android.com/reference/java/lang/Object.html> [LoadCallback](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadCallback#LoadCallback())()` **This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |

| ### Public methods |
|---|---|
| `abstract void` | `[onResult](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadCallback#onResult(kotlin.collections.List,kotlin.Any))(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull Value> data, Key adjacentPageKey)` **This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |

## Public constructors

### LoadCallback

```
public <Key extends Object, Value extends Object> [LoadCallback](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadCallback#LoadCallback())()
```

> [!CAUTION]
> **This method is deprecated.**   
> PageKeyedDataSource is deprecated and has been replaced by PagingSource, use this instead:
>
> ```
> PagingSource<Key, Value>
> ```

| Parameters |
|---|---|
| `<Key extends https://developer.android.com/reference/java/lang/Object.html>` | Type of data used to query pages. |
| `<Value extends https://developer.android.com/reference/java/lang/Object.html>` | Type of items being loaded. |

## Public methods

### onResult

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

```
public abstract void [onResult](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadCallback#onResult(kotlin.collections.List,kotlin.Any))(@NonNull List<@NonNull Value> data, Key adjacentPageKey)
```

> [!CAUTION]
> **This method is deprecated.**   
> PageKeyedDataSource is deprecated and has been replaced by PagingSource, use this instead:
>
> ```
> PagingSource<Key, Value>
> ```

Called to pass loaded data from a `https://developer.android.com/reference/androidx/paging/DataSource`.

Call this method from your PageKeyedDataSource's `https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadBefore(androidx.paging.PageKeyedDataSource.LoadParams)` and `https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadAfter(androidx.paging.PageKeyedDataSource.LoadParams)` methods to return data.

It is always valid to pass a different amount of data than what is requested. Pass an empty list if there is no more data to load.

Pass the key for the subsequent page to load to adjacentPageKey. For example, if you've loaded a page in `https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadBefore(androidx.paging.PageKeyedDataSource.LoadParams)`, pass the key for the previous page, or `null` if the loaded page is the first. If in `https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadAfter(androidx.paging.PageKeyedDataSource.LoadParams)`, pass the key for the next page, or `null` if the loaded page is the last.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull Value> data` | List of items loaded from the PageKeyedDataSource. |
| `Key adjacentPageKey` | Key for subsequent page load (previous page in `https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadBefore(androidx.paging.PageKeyedDataSource.LoadParams)` / next page in `https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadAfter(androidx.paging.PageKeyedDataSource.LoadParams)`), or `null` if there are no more pages to load in the current load direction. |