blob: af96663536027a70a2b7468c972e29e77146f83f [file] [log] [blame]
<html devsite="true">
<head>
<title>DataSource.Factory</title>
{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %}
{% include "_shared/_reference-head-tags.html" %}
</head>
<body>
<h1>DataSource.Factory</h1>
{% setvar page_path %}androidx/paging/DataSource.Factory.html{% endsetvar %}
{% setvar can_switch %}1{% endsetvar %}
{% include "reference/_kotlin_switcher2.md" %}
<p>
<pre>abstract class DataSource.Factory&lt;Key&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;Value&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt;</pre>
</p>
<hr>
<p>Factory for DataSources.</p>
<p>Data-loading systems of an application or library can implement this interface to allow <code>LiveData&lt;PagedList&gt;</code>s to be created. For example, Room can provide a <code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a></code> for a given SQL query:</p>
<pre class="prettyprint">@Dao<br>interface UserDao {<br> @Query(&quot;SELECT * FROM user ORDER BY lastName ASC&quot;)<br> public abstract DataSource.Factory&lt;Integer, User&gt; usersByLastName();<br>}</pre>
<p>In the above sample, <code>Integer</code> is used because it is the <code>Key</code> type of PositionalDataSource. Currently, Room uses the <code>LIMIT</code>/<code>OFFSET</code> SQL keywords to page a large query with a PositionalDataSource.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>&lt;Key&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt;</code></td>
<td width="100%">
<p>Key identifying items in DataSource.</p>
</td>
</tr>
<tr>
<td><code>&lt;Value&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt;</code></td>
<td width="100%">
<p>Type of items in the list loaded by the DataSources.</p>
</td>
</tr>
</tbody>
</table>
</div>
<h2>Summary</h2>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2"><h3>Public constructors</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div><code>&lt;Key&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;Value&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#Factory()">Factory</a>()</code></div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2"><h3>Public functions</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td><code>()&nbsp;-&gt;&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a>&lt;Key,&nbsp;Value&gt;</code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#asPagingSourceFactory(kotlinx.coroutines.CoroutineDispatcher)">asPagingSourceFactory</a>(fetchDispatcher:&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html">CoroutineDispatcher</a>)</code></div>
</td>
</tr>
<tr>
<td><code>abstract <a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a>&lt;Key,&nbsp;Value&gt;</code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#create()">create</a>()</code></div>
<p>Create a <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code>.</p>
</td>
</tr>
<tr>
<td><code>open <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a>&lt;Key,&nbsp;ToValue&gt;</code></td>
<td width="100%">
<div><code>&lt;ToValue&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#map()">map</a>(function:&nbsp;<a href="/reference/kotlin/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;Value,&nbsp;ToValue&gt;)</code></div>
<p>Applies the given function to each value emitted by DataSources produced by this Factory.</p>
</td>
</tr>
<tr>
<td><code>open <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a>&lt;Key,&nbsp;ToValue&gt;</code></td>
<td width="100%">
<div><code>&lt;ToValue&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#map(kotlin.Function1)">map</a>(function:&nbsp;(Value)&nbsp;-&gt;&nbsp;ToValue)</code></div>
<p>Applies the given function to each value emitted by DataSources produced by this Factory.</p>
</td>
</tr>
<tr>
<td><code>open <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a>&lt;Key,&nbsp;ToValue&gt;</code></td>
<td width="100%">
<div><code>&lt;ToValue&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#mapByPage()">mapByPage</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;function:&nbsp;<a href="/reference/kotlin/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;Value&gt;,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;ToValue&gt;&gt;<br>)</code></div>
<p>Applies the given function to each value emitted by DataSources produced by this Factory.</p>
</td>
</tr>
<tr>
<td><code>open <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a>&lt;Key,&nbsp;ToValue&gt;</code></td>
<td width="100%">
<div><code>&lt;ToValue&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#mapByPage(kotlin.Function1)">mapByPage</a>(function:&nbsp;(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;Value&gt;)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;ToValue&gt;)</code></div>
<p>Applies the given function to each value emitted by DataSources produced by this Factory.</p>
</td>
</tr>
</tbody>
</table>
</div>
<h2>Public constructors</h2>
<div><a name="Factory--"></a>
<h3 class="api-name" id="Factory()">Factory</h3>
<pre class="api-signature no-pretty-print">&lt;Key&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;Value&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#Factory()">Factory</a>()</pre>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>&lt;Key&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt;</code></td>
<td width="100%">
<p>Key identifying items in DataSource.</p>
</td>
</tr>
<tr>
<td><code>&lt;Value&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt;</code></td>
<td width="100%">
<p>Type of items in the list loaded by the DataSources.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h2>Public functions</h2>
<div><a name="asPagingSourceFactory-kotlinx.coroutines.CoroutineDispatcher-"></a>
<h3 class="api-name" id="asPagingSourceFactory(kotlinx.coroutines.CoroutineDispatcher)">asPagingSourceFactory</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;<a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#asPagingSourceFactory(kotlinx.coroutines.CoroutineDispatcher)">asPagingSourceFactory</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;fetchDispatcher:&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html">CoroutineDispatcher</a> = Dispatchers.IO<br>):&nbsp;()&nbsp;-&gt;&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a>&lt;Key,&nbsp;Value&gt;</pre>
</div>
<div><a name="create--"></a>
<h3 class="api-name" id="create()">create</h3>
<pre class="api-signature no-pretty-print">abstract&nbsp;fun&nbsp;<a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#create()">create</a>():&nbsp;<a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a>&lt;Key,&nbsp;Value&gt;</pre>
<p>Create a <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code>.</p>
<p>The <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code> should invalidate itself if the snapshot is no longer valid. If a <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code> becomes invalid, the only way to query more data is to create a new <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code> from the Factory.</p>
<p><code><a href="/reference/kotlin/androidx/paging/LivePagedListBuilder.html">androidx.paging.LivePagedListBuilder</a></code> for example will construct a new PagedList and DataSource when the current DataSource is invalidated, and pass the new PagedList through the <code>LiveData&lt;PagedList&gt;</code> to observers.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a>&lt;Key,&nbsp;Value&gt;</code></td>
<td width="100%">
<p>the new DataSource.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="map--"></a>
<h3 class="api-name" id="map()">map</h3>
<pre class="api-signature no-pretty-print">open&nbsp;fun&nbsp;&lt;ToValue&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#map()">map</a>(function:&nbsp;<a href="/reference/kotlin/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;Value,&nbsp;ToValue&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a>&lt;Key,&nbsp;ToValue&gt;</pre>
<p>Applies the given function to each value emitted by DataSources produced by this Factory.</p>
<p>Same as <code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#mapByPage()">mapByPage</a></code>, but operates on individual items.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a>&lt;Key,&nbsp;ToValue&gt;</code></td>
<td width="100%">
<p>A new <code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a></code>, which transforms items using the given function.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>&lt;ToValue&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt;</code></td>
<td width="100%">
<p>Type of items produced by the new <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code>, from the passed function.</p>
</td>
</tr>
<tr>
<td><code>function:&nbsp;<a href="/reference/kotlin/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;Value,&nbsp;ToValue&gt;</code></td>
<td width="100%">
<p>Function that runs on each loaded item, returning items of a potentially new type.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#mapByPage()">mapByPage</a></code></td>
<td width="100%"></td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.html#map()">map</a></code></td>
<td width="100%"></td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.html#mapByPage()">mapByPage</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="map-kotlin.Function1-"></a>
<h3 class="api-name" id="map(kotlin.Function1)">map</h3>
<pre class="api-signature no-pretty-print">open&nbsp;fun&nbsp;&lt;ToValue&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#map(kotlin.Function1)">map</a>(function:&nbsp;(Value)&nbsp;-&gt;&nbsp;ToValue):&nbsp;<a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a>&lt;Key,&nbsp;ToValue&gt;</pre>
<p>Applies the given function to each value emitted by DataSources produced by this Factory.</p>
<p>An overload of <code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#map()">map</a></code> that accepts a kotlin function type.</p>
<p>Same as <code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#mapByPage()">mapByPage</a></code>, but operates on individual items.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a>&lt;Key,&nbsp;ToValue&gt;</code></td>
<td width="100%">
<p>A new <code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a></code>, which transforms items using the given function.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>&lt;ToValue&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt;</code></td>
<td width="100%">
<p>Type of items produced by the new <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code>, from the passed function.</p>
</td>
</tr>
<tr>
<td><code>function:&nbsp;(Value)&nbsp;-&gt;&nbsp;ToValue</code></td>
<td width="100%">
<p>Function that runs on each loaded item, returning items of a potentially new type.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#mapByPage()">mapByPage</a></code></td>
<td width="100%"></td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.html#map()">map</a></code></td>
<td width="100%"></td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.html#mapByPage()">mapByPage</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="mapByPage--"></a>
<h3 class="api-name" id="mapByPage()">mapByPage</h3>
<pre class="api-signature no-pretty-print">open&nbsp;fun&nbsp;&lt;ToValue&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#mapByPage()">mapByPage</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;function:&nbsp;<a href="/reference/kotlin/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;Value&gt;,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;ToValue&gt;&gt;<br>):&nbsp;<a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a>&lt;Key,&nbsp;ToValue&gt;</pre>
<p>Applies the given function to each value emitted by DataSources produced by this Factory.</p>
<p>Same as <code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#map()">map</a></code>, but allows for batch conversions.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a>&lt;Key,&nbsp;ToValue&gt;</code></td>
<td width="100%">
<p>A new <code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a></code>, which transforms items using the given function.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>&lt;ToValue&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt;</code></td>
<td width="100%">
<p>Type of items produced by the new <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code>, from the passed function.</p>
</td>
</tr>
<tr>
<td><code>function:&nbsp;<a href="/reference/kotlin/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;Value&gt;,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;ToValue&gt;&gt;</code></td>
<td width="100%">
<p>Function that runs on each loaded page, returning items of a potentially new type.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#map()">map</a></code></td>
<td width="100%"></td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.html#map()">map</a></code></td>
<td width="100%"></td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.html#mapByPage()">mapByPage</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="mapByPage-kotlin.Function1-"></a>
<h3 class="api-name" id="mapByPage(kotlin.Function1)">mapByPage</h3>
<pre class="api-signature no-pretty-print">open&nbsp;fun&nbsp;&lt;ToValue&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#mapByPage(kotlin.Function1)">mapByPage</a>(function:&nbsp;(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;Value&gt;)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;ToValue&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a>&lt;Key,&nbsp;ToValue&gt;</pre>
<p>Applies the given function to each value emitted by DataSources produced by this Factory.</p>
<p>An overload of <code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#mapByPage()">mapByPage</a></code> that accepts a kotlin function type.</p>
<p>Same as <code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#map()">map</a></code>, but allows for batch conversions.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a>&lt;Key,&nbsp;ToValue&gt;</code></td>
<td width="100%">
<p>A new <code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html">DataSource.Factory</a></code>, which transforms items using the given function.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>&lt;ToValue&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt;</code></td>
<td width="100%">
<p>Type of items produced by the new <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code>, from the passed function.</p>
</td>
</tr>
<tr>
<td><code>function:&nbsp;(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;Value&gt;)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;ToValue&gt;</code></td>
<td width="100%">
<p>Function that runs on each loaded page, returning items of a potentially new type.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.Factory.html#map()">map</a></code></td>
<td width="100%"></td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.html#map()">map</a></code></td>
<td width="100%"></td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/DataSource.html#mapByPage()">mapByPage</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>