# PageKeyedDataSource

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) 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<Key extends Object, Value extends Object> extends DataSource<@NonNull Key, @NonNull Value>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.paging.DataSource](https://developer.android.com/reference/androidx/paging/DataSource)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) Key, @[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) Value\> ||
|   | ↳ | [androidx.paging.PageKeyedDataSource](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource) |

*** ** * ** ***

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

Incremental data loader for page-keyed content, where requests return keys for next/previous pages.

Implement a `https://developer.android.com/reference/androidx/paging/DataSource` using `https://developer.android.com/reference/androidx/paging/PageKeyedDataSource` if you need to use data from page `N - 1` to load page `N`. This is common, for example, in network APIs that include a next/previous link or key with each page load.

The `InMemoryByPageRepository` in the [PagingWithNetworkSample](https://github.com/googlesamples/android-architecture-components/blob/master/PagingWithNetworkSample/README.md) shows how to implement a network PageKeyedDataSource using [Retrofit](https://square.github.io/retrofit/), while handling swipe-to-refresh, network errors, and retry.

| Parameters |
|---|---|
| `<Key extends https://developer.android.com/reference/java/lang/Object.html>` | Type of data used to query Value types out of the `https://developer.android.com/reference/androidx/paging/DataSource`. |
| `<Value extends https://developer.android.com/reference/java/lang/Object.html>` | Type of items being loaded by the `https://developer.android.com/reference/androidx/paging/DataSource`. |

## Summary

| ### Nested types |
|---|
| `public abstract class https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadCallback<Key extends https://developer.android.com/reference/java/lang/Object.html, Value extends https://developer.android.com/reference/java/lang/Object.html>` **This class is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |
| `public abstract class https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadInitialCallback<Key extends https://developer.android.com/reference/java/lang/Object.html, Value extends https://developer.android.com/reference/java/lang/Object.html>` **This class is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |
| `public class https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadInitialParams<Key extends https://developer.android.com/reference/java/lang/Object.html>` **This class is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |
| `public class https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadParams<Key extends https://developer.android.com/reference/java/lang/Object.html>` **This class is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |

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

| ### Public methods |
|---|---|
| `abstract void` | `[loadAfter](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadAfter(androidx.paging.PageKeyedDataSource.LoadParams,androidx.paging.PageKeyedDataSource.LoadCallback))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadParams<@https://developer.android.com/reference/androidx/annotation/NonNull Key> params, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadCallback<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull Value> callback )` **This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |
| `abstract void` | `[loadBefore](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadBefore(androidx.paging.PageKeyedDataSource.LoadParams,androidx.paging.PageKeyedDataSource.LoadCallback))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadParams<@https://developer.android.com/reference/androidx/annotation/NonNull Key> params, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadCallback<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull Value> callback )` **This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |
| `abstract void` | `[loadInitial](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadInitial(androidx.paging.PageKeyedDataSource.LoadInitialParams,androidx.paging.PageKeyedDataSource.LoadInitialCallback))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadInitialParams<@https://developer.android.com/reference/androidx/annotation/NonNull Key> params, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadInitialCallback<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull Value> callback )` **This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull ToValue>` | `<ToValue extends https://developer.android.com/reference/java/lang/Object.html> [map](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#map(androidx.arch.core.util.Function))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/arch/core/util/Function<@https://developer.android.com/reference/androidx/annotation/NonNull Value, @https://developer.android.com/reference/androidx/annotation/NonNull ToValue> function )` **This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull ToValue>` | `<ToValue extends https://developer.android.com/reference/java/lang/Object.html> [map](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#map(kotlin.Function1))( @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull Value, @https://developer.android.com/reference/androidx/annotation/NonNull ToValue> function )` **This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull ToValue>` | `<ToValue extends https://developer.android.com/reference/java/lang/Object.html> [mapByPage](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#mapByPage(androidx.arch.core.util.Function))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/arch/core/util/Function<@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>, @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 ToValue>> function )` **This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull ToValue>` | `<ToValue extends https://developer.android.com/reference/java/lang/Object.html> [mapByPage](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#mapByPage(kotlin.Function1))( @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@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>, @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 ToValue>> function )` **This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource |

### Inherited methods

From [androidx.paging.DataSource](https://developer.android.com/reference/androidx/paging/DataSource) `void` `@https://developer.android.com/reference/androidx/annotation/AnyThread
[addInvalidatedCallback](https://developer.android.com/reference/androidx/paging/DataSource#addInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback))(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/DataSource.InvalidatedCallback onInvalidatedCallback
)`

**This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource
`void` `@https://developer.android.com/reference/androidx/annotation/AnyThread
[invalidate](https://developer.android.com/reference/androidx/paging/DataSource#invalidate())()`

**This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource
`boolean` `@https://developer.android.com/reference/androidx/annotation/WorkerThread
[isInvalid](https://developer.android.com/reference/androidx/paging/DataSource#isInvalid())()`

**This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource
`void` `@https://developer.android.com/reference/androidx/annotation/AnyThread
[removeInvalidatedCallback](https://developer.android.com/reference/androidx/paging/DataSource#removeInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback))(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/DataSource.InvalidatedCallback onInvalidatedCallback
)`

**This method is deprecated.** PageKeyedDataSource is deprecated and has been replaced by PagingSource

## Public constructors

### PageKeyedDataSource

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

> [!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 Value types out of the `https://developer.android.com/reference/androidx/paging/DataSource`. |
| `<Value extends https://developer.android.com/reference/java/lang/Object.html>` | Type of items being loaded by the `https://developer.android.com/reference/androidx/paging/DataSource`. |

## Public methods

### loadAfter

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 void [loadAfter](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadAfter(androidx.paging.PageKeyedDataSource.LoadParams,androidx.paging.PageKeyedDataSource.LoadCallback))(
    @NonNull PageKeyedDataSource.LoadParams<@NonNull Key> params,
    @NonNull PageKeyedDataSource.LoadCallback<@NonNull Key, @NonNull Value> callback
)
```

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

Append page with the key specified by `https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadParams#key()`.

It's valid to return a different list size than the page size if it's easier, e.g. if your backend defines page sizes. It is generally preferred to increase the number loaded than reduce.

Data may be passed synchronously during the load method, or deferred and called at a later time. Further loads going down will be blocked until the callback is called.

If data cannot be loaded (for example, if the request is invalid, or the data would be stale and inconsistent), it is valid to call `https://developer.android.com/reference/androidx/paging/DataSource#invalidate()` to invalidate the data source, and prevent further loading.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadParams<@https://developer.android.com/reference/androidx/annotation/NonNull Key> params` | Parameters for the load, including the key for the new page, and requested load size. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadCallback<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull Value> callback` | Callback that receives loaded data. |

### loadBefore

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 void [loadBefore](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadBefore(androidx.paging.PageKeyedDataSource.LoadParams,androidx.paging.PageKeyedDataSource.LoadCallback))(
    @NonNull PageKeyedDataSource.LoadParams<@NonNull Key> params,
    @NonNull PageKeyedDataSource.LoadCallback<@NonNull Key, @NonNull Value> callback
)
```

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

Prepend page with the key specified by `https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadParams#key()`.

It's valid to return a different list size than the page size if it's easier, e.g. if your backend defines page sizes. It is generally preferred to increase the number loaded than reduce.

Data may be passed synchronously during the load method, or deferred and called at a later time. Further loads going down will be blocked until the callback is called.

If data cannot be loaded (for example, if the request is invalid, or the data would be stale and inconsistent), it is valid to call `https://developer.android.com/reference/androidx/paging/DataSource#invalidate()` to invalidate the data source, and prevent further loading.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadParams<@https://developer.android.com/reference/androidx/annotation/NonNull Key> params` | Parameters for the load, including the key for the new page, and requested load size. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadCallback<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull Value> callback` | Callback that receives loaded data. |

### loadInitial

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 void [loadInitial](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#loadInitial(androidx.paging.PageKeyedDataSource.LoadInitialParams,androidx.paging.PageKeyedDataSource.LoadInitialCallback))(
    @NonNull PageKeyedDataSource.LoadInitialParams<@NonNull Key> params,
    @NonNull PageKeyedDataSource.LoadInitialCallback<@NonNull Key, @NonNull Value> callback
)
```

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

Load initial data.

This method is called first to initialize a PagedList with data. If it's possible to count the items that can be loaded by the DataSource, it's recommended to pass the loaded data to the callback via the three-parameter `https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadInitialCallback#onResult(kotlin.collections.List,kotlin.Int,kotlin.Int,kotlin.Any,kotlin.Any)`. This enables PagedLists presenting data from this source to display placeholders to represent unloaded items.

`https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadInitialParams#requestedLoadSize()` is a hint, not a requirement, so it may be may be altered or ignored.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadInitialParams<@https://developer.android.com/reference/androidx/annotation/NonNull Key> params` | Parameters for initial load, including requested load size. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource.LoadInitialCallback<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull Value> callback` | Callback that receives initial load data. |

### map

```
public final @NonNull PageKeyedDataSource<@NonNull Key, @NonNull ToValue> <ToValue extends Object> [map](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#map(androidx.arch.core.util.Function))(
    @NonNull Function<@NonNull Value, @NonNull ToValue> function
)
```

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

Applies the given function to each value emitted by the DataSource.

Same as `https://developer.android.com/reference/androidx/paging/DataSource#mapByPage(androidx.arch.core.util.Function)`, but operates on individual items.

| Parameters |
|---|---|
| `<ToValue extends https://developer.android.com/reference/java/lang/Object.html>` | Type of items produced by the new DataSource, from the passed function. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/arch/core/util/Function<@https://developer.android.com/reference/androidx/annotation/NonNull Value, @https://developer.android.com/reference/androidx/annotation/NonNull ToValue> function` | Function that runs on each loaded item, returning items of a potentially new type. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull ToValue>` | A new DataSource, which transforms items using the given function. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/paging/DataSource#mapByPage(androidx.arch.core.util.Function)` |   |
| `https://developer.android.com/reference/androidx/paging/DataSource.Factory#map(androidx.arch.core.util.Function)` |   |
| `https://developer.android.com/reference/androidx/paging/DataSource.Factory#mapByPage(androidx.arch.core.util.Function)` |   |

### map

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

```
public final @NonNull PageKeyedDataSource<@NonNull Key, @NonNull ToValue> <ToValue extends Object> [map](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#map(kotlin.Function1))(
    @NonNull Function1<@NonNull Value, @NonNull ToValue> function
)
```

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

Applies the given function to each value emitted by the DataSource.

An overload of `https://developer.android.com/reference/androidx/paging/DataSource#map(kotlin.Function1)` that accepts a kotlin function type.

Same as `https://developer.android.com/reference/androidx/paging/DataSource#mapByPage(androidx.arch.core.util.Function)`, but operates on individual items.

| Parameters |
|---|---|
| `<ToValue extends https://developer.android.com/reference/java/lang/Object.html>` | Type of items produced by the new DataSource, from the passed function. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull Value, @https://developer.android.com/reference/androidx/annotation/NonNull ToValue> function` | Function that runs on each loaded item, returning items of a potentially new type. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull ToValue>` | A new DataSource, which transforms items using the given function. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/paging/DataSource#mapByPage(androidx.arch.core.util.Function)` |   |
| `https://developer.android.com/reference/androidx/paging/DataSource.Factory#map(androidx.arch.core.util.Function)` |   |

### mapByPage

```
public final @NonNull PageKeyedDataSource<@NonNull Key, @NonNull ToValue> <ToValue extends Object> [mapByPage](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#mapByPage(androidx.arch.core.util.Function))(
    @NonNull Function<@NonNull List<@NonNull Value>, @NonNull List<@NonNull ToValue>> function
)
```

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

Applies the given function to each value emitted by the DataSource.

Same as `https://developer.android.com/reference/androidx/paging/DataSource#map(androidx.arch.core.util.Function)`, but allows for batch conversions.

| Parameters |
|---|---|
| `<ToValue extends https://developer.android.com/reference/java/lang/Object.html>` | Type of items produced by the new DataSource, from the passed function. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/arch/core/util/Function<@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>, @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 ToValue>> function` | Function that runs on each loaded page, returning items of a potentially new type. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull ToValue>` | A new DataSource, which transforms items using the given function. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/paging/DataSource#map(androidx.arch.core.util.Function)` |   |
| `https://developer.android.com/reference/androidx/paging/DataSource.Factory#map(androidx.arch.core.util.Function)` |   |
| `https://developer.android.com/reference/androidx/paging/DataSource.Factory#mapByPage(androidx.arch.core.util.Function)` |   |

### mapByPage

```
public final @NonNull PageKeyedDataSource<@NonNull Key, @NonNull ToValue> <ToValue extends Object> [mapByPage](https://developer.android.com/reference/androidx/paging/PageKeyedDataSource#mapByPage(kotlin.Function1))(
    @NonNull Function1<@NonNull List<@NonNull Value>, @NonNull List<@NonNull ToValue>> function
)
```

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

Applies the given function to each value emitted by the DataSource.

An overload of `https://developer.android.com/reference/androidx/paging/DataSource#mapByPage(kotlin.Function1)` that accepts a kotlin function type.

Same as `https://developer.android.com/reference/androidx/paging/DataSource#map(androidx.arch.core.util.Function)`, but allows for batch conversions.

| Parameters |
|---|---|
| `<ToValue extends https://developer.android.com/reference/java/lang/Object.html>` | Type of items produced by the new DataSource, from the passed function. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@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>, @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 ToValue>> function` | Function that runs on each loaded page, returning items of a potentially new type. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PageKeyedDataSource<@https://developer.android.com/reference/androidx/annotation/NonNull Key, @https://developer.android.com/reference/androidx/annotation/NonNull ToValue>` | A new `https://developer.android.com/reference/androidx/paging/DataSource`, which transforms items using the given function. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/paging/DataSource#map(androidx.arch.core.util.Function)` |   |
| `https://developer.android.com/reference/androidx/paging/DataSource.Factory#map(androidx.arch.core.util.Function)` |   |
| `https://developer.android.com/reference/androidx/paging/DataSource.Factory#mapByPage(androidx.arch.core.util.Function)` |   |