# ItemKeyedDataSource

Artifact: [androidx.paging:paging-common](https://developer.android.com/jetpack/androidx/releases/paging) [View Source](https://cs.android.com/search?q=file:androidx/paging/ItemKeyedDataSource.jvmAndAndroid.kt+class:androidx.paging.ItemKeyedDataSource) 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)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOSJavaScript
- android

  ```
  abstract class ItemKeyedDataSource<Key : Any, Value : Any> : DataSource<Key, Value>
  ```

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.paging.DataSource](https://developer.android.com/reference/kotlin/androidx/paging/DataSource)\<Key, Value\> ||
|   | ↳ | [androidx.paging.ItemKeyedDataSource](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource) |

*** ** * ** ***

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

Incremental data loader for paging keyed content, where loaded content uses previously loaded items as input to future loads.

Implement a DataSource using ItemKeyedDataSource if you need to use data from item `N - 1` to load item `N`. This is common, for example, in uniquely sorted database queries where attributes of the item such just before the next query define how to execute it.

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

| Parameters |
|---|---|
| `<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of data used to query Value types out of the `https://developer.android.com/reference/kotlin/androidx/paging/DataSource`. |
| `<Value : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of items being loaded by the `https://developer.android.com/reference/kotlin/androidx/paging/DataSource`. |

## Summary

| ### Nested types |
|---|
| `abstract class https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadCallback<Value : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` **This class is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource |
| `abstract class https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadInitialCallback<Value : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> : https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadCallback<Value>` **This class is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource |
| `open class https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadInitialParams<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` **This class is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource |
| `open class https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadParams<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` **This class is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource |

| ### 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> [ItemKeyedDataSource](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#ItemKeyedDataSource())()` **This function is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource | android |

| ### Public functions |
|---|---|---|
| `abstract Key` | `[getKey](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#getKey(kotlin.Any))(item: Value)` **This function is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource | android |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[loadAfter](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#loadAfter(androidx.paging.ItemKeyedDataSource.LoadParams,androidx.paging.ItemKeyedDataSource.LoadCallback))( params: https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadParams<Key>, callback: https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadCallback<Value> )` **This function is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource | android |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[loadBefore](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#loadBefore(androidx.paging.ItemKeyedDataSource.LoadParams,androidx.paging.ItemKeyedDataSource.LoadCallback))( params: https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadParams<Key>, callback: https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadCallback<Value> )` **This function is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource | android |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[loadInitial](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#loadInitial(androidx.paging.ItemKeyedDataSource.LoadInitialParams,androidx.paging.ItemKeyedDataSource.LoadInitialCallback))( params: https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadInitialParams<Key>, callback: https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadInitialCallback<Value> )` **This function is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource | android |
| `final https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource<Key, ToValue>` | `<ToValue : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> [map](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#map(androidx.arch.core.util.Function))(function: https://developer.android.com/reference/kotlin/androidx/arch/core/util/Function<Value, ToValue>)` **This function is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource | android |
| `final https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource<Key, ToValue>` | `<ToValue : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> [map](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#map(kotlin.Function1))(function: (Value) -> ToValue)` **This function is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource | android |
| `final https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource<Key, ToValue>` | `<ToValue : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> [mapByPage](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#mapByPage(androidx.arch.core.util.Function))(function: https://developer.android.com/reference/kotlin/androidx/arch/core/util/Function<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<Value>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<ToValue>>)` **This function is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource | android |
| `final https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource<Key, ToValue>` | `<ToValue : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> [mapByPage](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#mapByPage(kotlin.Function1))(function: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<Value>) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<ToValue>)` **This function is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource | android |

### Inherited functions

From [androidx.paging.DataSource](https://developer.android.com/reference/kotlin/androidx/paging/DataSource) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread
[addInvalidatedCallback](https://developer.android.com/reference/kotlin/androidx/paging/DataSource#addInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback))(
onInvalidatedCallback: https://developer.android.com/reference/kotlin/androidx/paging/DataSource.InvalidatedCallback
)`

**This function is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource
android `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread
[invalidate](https://developer.android.com/reference/kotlin/androidx/paging/DataSource#invalidate())()`

**This function is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource
android `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/AnyThread
[removeInvalidatedCallback](https://developer.android.com/reference/kotlin/androidx/paging/DataSource#removeInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback))(
onInvalidatedCallback: https://developer.android.com/reference/kotlin/androidx/paging/DataSource.InvalidatedCallback
)`

**This function is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource
android

### Inherited properties

From [androidx.paging.DataSource](https://developer.android.com/reference/kotlin/androidx/paging/DataSource) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/paging/DataSource#isInvalid()`

**This property is deprecated.** ItemKeyedDataSource is deprecated and has been replaced by PagingSource
android

## Public constructors

### ItemKeyedDataSource

android

```
<Key : Any, Value : Any> [ItemKeyedDataSource](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#ItemKeyedDataSource())()
```

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

| Parameters |
|---|---|
| `<Key : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of data used to query Value types out of the `https://developer.android.com/reference/kotlin/androidx/paging/DataSource`. |
| `<Value : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of items being loaded by the `https://developer.android.com/reference/kotlin/androidx/paging/DataSource`. |

## Public functions

### getKey

android 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)

```
abstract fun [getKey](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#getKey(kotlin.Any))(item: Value): Key
```

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

Return a key associated with the given item.

If your ItemKeyedDataSource is loading from a source that is sorted and loaded by a unique integer ID, you would return `item.getID()` here. This key can then be passed to `https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#loadBefore(androidx.paging.ItemKeyedDataSource.LoadParams)` or `https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#loadAfter(androidx.paging.ItemKeyedDataSource.LoadParams)` to load additional items adjacent to the item passed to this function.

If your key is more complex, such as when you're sorting by name, then resolving collisions with integer ID, you'll need to return both. In such a case you would use a wrapper class, such as `Pair<String, Integer>` or, in Kotlin, `data class Key(val name: String, val id: Int)`

| Parameters |
|---|---|
| `item: Value` | Item to get the key from. |

| Returns |
|---|---|
| `Key` | Key associated with given item. |

### loadAfter

android 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)

```
abstract fun [loadAfter](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#loadAfter(androidx.paging.ItemKeyedDataSource.LoadParams,androidx.paging.ItemKeyedDataSource.LoadCallback))(
    params: ItemKeyedDataSource.LoadParams<Key>,
    callback: ItemKeyedDataSource.LoadCallback<Value>
): Unit
```

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

Load list data after the key specified in `https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.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 loadAfter 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/kotlin/androidx/paging/DataSource#invalidate()` to invalidate the data source, and prevent further loading.

| Parameters |
|---|---|
| `params: https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadParams<Key>` | Parameters for the load, including the key to load after, and requested size. |
| `callback: https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadCallback<Value>` | Callback that receives loaded data. |

### loadBefore

android 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)

```
abstract fun [loadBefore](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#loadBefore(androidx.paging.ItemKeyedDataSource.LoadParams,androidx.paging.ItemKeyedDataSource.LoadCallback))(
    params: ItemKeyedDataSource.LoadParams<Key>,
    callback: ItemKeyedDataSource.LoadCallback<Value>
): Unit
```

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

Load list data before the key specified in `https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.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.

**Note:** Data returned will be prepended just before the key passed, so if you vary size, ensure that the last item is adjacent to the passed key.

Data may be passed synchronously during the loadBefore method, or deferred and called at a later time. Further loads going up 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/kotlin/androidx/paging/DataSource#invalidate()` to invalidate the data source, and prevent further loading.

| Parameters |
|---|---|
| `params: https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadParams<Key>` | Parameters for the load, including the key to load before, and requested size. |
| `callback: https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadCallback<Value>` | Callback that receives loaded data. |

### loadInitial

android 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)

```
abstract fun [loadInitial](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#loadInitial(androidx.paging.ItemKeyedDataSource.LoadInitialParams,androidx.paging.ItemKeyedDataSource.LoadInitialCallback))(
    params: ItemKeyedDataSource.LoadInitialParams<Key>,
    callback: ItemKeyedDataSource.LoadInitialCallback<Value>
): Unit
```

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

Load initial data.

This method is called first to initialize a `https://developer.android.com/reference/kotlin/androidx/paging/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/kotlin/androidx/paging/ItemKeyedDataSource.LoadInitialCallback#onResult(kotlin.collections.List,kotlin.Int,kotlin.Int)`. This enables PagedLists presenting data from this source to display placeholders to represent unloaded items.

`https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadInitialParams#requestedInitialKey()` and `https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource.LoadInitialParams#requestedLoadSize()` are hints, not requirements, so they may be altered or ignored. Note that ignoring the `requestedInitialKey` can prevent subsequent PagedList/DataSource pairs from initializing at the same location. If your DataSource never invalidates (for example, loading from the network without the network ever signalling that old data must be reloaded), it's fine to ignore the `initialLoadKey` and always start from the beginning of the data set.

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

### map

android

```
final fun <ToValue : Any> [map](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#map(androidx.arch.core.util.Function))(function: Function<Value, ToValue>): ItemKeyedDataSource<Key, ToValue>
```

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

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

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

| Parameters |
|---|---|
| `<ToValue : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of items produced by the new DataSource, from the passed function. |
| `function: https://developer.android.com/reference/kotlin/androidx/arch/core/util/Function<Value, ToValue>` | Function that runs on each loaded item, returning items of a potentially new type. |

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

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

### map

android 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)

```
final fun <ToValue : Any> [map](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#map(kotlin.Function1))(function: (Value) -> ToValue): ItemKeyedDataSource<Key, ToValue>
```

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

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

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

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

| Parameters |
|---|---|
| `<ToValue : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of items produced by the new DataSource, from the passed function. |
| `function: (Value) -> ToValue` | Function that runs on each loaded item, returning items of a potentially new type. |

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

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

### mapByPage

android

```
final fun <ToValue : Any> [mapByPage](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#mapByPage(androidx.arch.core.util.Function))(function: Function<List<Value>, List<ToValue>>): ItemKeyedDataSource<Key, ToValue>
```

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

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

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

| Parameters |
|---|---|
| `<ToValue : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of items produced by the new DataSource, from the passed function. |
| `function: https://developer.android.com/reference/kotlin/androidx/arch/core/util/Function<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<Value>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<ToValue>>` | Function that runs on each loaded page, returning items of a potentially new type. |

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

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

### mapByPage

android

```
final fun <ToValue : Any> [mapByPage](https://developer.android.com/reference/kotlin/androidx/paging/ItemKeyedDataSource#mapByPage(kotlin.Function1))(function: (List<Value>) -> List<ToValue>): ItemKeyedDataSource<Key, ToValue>
```

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

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

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

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

| Parameters |
|---|---|
| `<ToValue : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of items produced by the new DataSource, from the passed function. |
| `function: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<Value>) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<ToValue>` | Function that runs on each loaded page, returning items of a potentially new type. |

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

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