blob: 546703b5406ad7ba00c710dac7e7d13d9825a9ce [file] [log] [blame]
<html devsite="true">
<head>
<title>AsyncPagingDataDiffer</title>
{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %}
{% include "_shared/_reference-head-tags.html" %}
</head>
<body>
<h1>AsyncPagingDataDiffer</h1>
{% setvar page_path %}androidx/paging/AsyncPagingDataDiffer.html{% endsetvar %}
{% setvar can_switch %}1{% endsetvar %}
{% include "reference/_kotlin_switcher2.md" %}
<p>
<pre>class AsyncPagingDataDiffer&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt;</pre>
</p>
<hr>
<p>Helper class for mapping a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> into a <a href="[androidx.recyclerview.widget.RecyclerView.Adapter]">androidx.recyclerview.widget.RecyclerView.Adapter</a>.</p>
<p>For simplicity, <code><a href="/reference/kotlin/androidx/paging/PagingDataAdapter.html">PagingDataAdapter</a></code> can often be used in place of this class. <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html">AsyncPagingDataDiffer</a></code> is exposed for complex cases, and where overriding <code><a href="/reference/kotlin/androidx/paging/PagingDataAdapter.html">PagingDataAdapter</a></code> to support paging isn't convenient.</p>
<h2>Summary</h2>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2"><h3>Public properties</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td><code>@<a href="/reference/kotlin/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a>&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>&gt;</code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#dataRefreshFlow()">dataRefreshFlow</a></code></div>
<p><strong>This property is deprecated.</strong> dataRefreshFlow is now redundant with the information passed from loadStateFlow and getItemCount, and will be removed in a future alpha version</p>
</td>
</tr>
<tr>
<td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a></code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#itemCount()">itemCount</a></code></div>
<p>Get the number of items currently presented by this Differ.</p>
</td>
</tr>
<tr>
<td><code>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-opt-in/index.html">OptIn</a>(markerClass&nbsp;=&nbsp;[FlowPreview])&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a>&lt;<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>&gt;</code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#loadStateFlow()">loadStateFlow</a></code></div>
<p>A hot <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a></code> of <code><a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> that emits a snapshot whenever the loading state of the current <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> changes.</p>
</td>
</tr>
</tbody>
</table>
</div>
<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;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#AsyncPagingDataDiffer(DiffUtil.ItemCallback&lt;T&gt;,ListUpdateCallback,kotlinx.coroutines.CoroutineDispatcher,kotlinx.coroutines.CoroutineDispatcher)">AsyncPagingDataDiffer</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;diffCallback:&nbsp;<a href="/reference/kotlin/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;T&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;updateCallback:&nbsp;<a href="/reference/kotlin/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;mainDispatcher:&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html">CoroutineDispatcher</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;workerDispatcher:&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html">CoroutineDispatcher</a><br>)</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>@<a href="/reference/kotlin/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
<td width="100%">
<div><code><span><del><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#addDataRefreshListener(kotlin.Function1)">addDataRefreshListener</a></del></span>(listener:&nbsp;(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>)</code></div>
<p><strong>This function is deprecated.</strong> dataRefreshListener is now redundant with the information passed from loadStateListener and getItemCount, and will be removed in a future alpha version</p>
</td>
</tr>
<tr>
<td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#addLoadStateListener(kotlin.Function1)">addLoadStateListener</a>(listener:&nbsp;(<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>)</code></div>
<p>Add a <code><a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> listener to observe the loading state of the current <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code>.</p>
</td>
</tr>
<tr>
<td><code>T?</code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#getItem(kotlin.Int)">getItem</a>(@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/-int-range/index.html">IntRange</a>&nbsp;index:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a>)</code></div>
<p>Get the item from the current PagedList at the specified index.</p>
</td>
</tr>
<tr>
<td><code>T?</code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#peek(kotlin.Int)">peek</a>(@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/-int-range/index.html">IntRange</a>&nbsp;index:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a>)</code></div>
<p>Returns the presented item at the specified position, without notifying Paging of the item access that would normally trigger page loads.</p>
</td>
</tr>
<tr>
<td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a>()</code></div>
<p>Refresh the data presented by this <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html">AsyncPagingDataDiffer</a></code>.</p>
</td>
</tr>
<tr>
<td><code>@<a href="/reference/kotlin/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
<td width="100%">
<div><code><span><del><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#removeDataRefreshListener(kotlin.Function1)">removeDataRefreshListener</a></del></span>(listener:&nbsp;(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>)</code></div>
<p><strong>This function is deprecated.</strong> dataRefreshListener is now redundant with the information passed from loadStateListener and getItemCount, and will be removed in a future alpha version</p>
</td>
</tr>
<tr>
<td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#removeLoadStateListener(kotlin.Function1)">removeLoadStateListener</a>(listener:&nbsp;(<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>)</code></div>
<p>Remove a previously registered <code><a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> listener.</p>
</td>
</tr>
<tr>
<td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#retry()">retry</a>()</code></div>
<p>Retry any failed load requests that would result in a <code><a href="/reference/kotlin/androidx/paging/LoadState.Error.html">LoadState.Error</a></code> update to this <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html">AsyncPagingDataDiffer</a></code>.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/ItemSnapshotList.html">ItemSnapshotList</a>&lt;T&gt;</code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#snapshot()">snapshot</a>()</code></div>
<p>Returns a new <code><a href="/reference/kotlin/androidx/paging/ItemSnapshotList.html">ItemSnapshotList</a></code> representing the currently presented items, including any placeholders if they are enabled.</p>
</td>
</tr>
<tr>
<td><code>suspend <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a>(pagingData:&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;)</code></div>
<p>Present a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> until it is invalidated by a call to <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a></code> or <code><a href="/reference/kotlin/androidx/paging/PagingSource.html#invalidate()">PagingSource.invalidate</a></code>.</p>
</td>
</tr>
<tr>
<td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
<td width="100%">
<div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(Lifecycle,androidx.paging.PagingData)">submitData</a>(lifecycle:&nbsp;<a href="/reference/kotlin/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>,&nbsp;pagingData:&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;)</code></div>
<p>Present a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> until it is either invalidated or another call to <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code> is made.</p>
</td>
</tr>
</tbody>
</table>
</div>
<h2>Public properties</h2>
<div><a name="getDataRefreshFlow()"></a><a name="setDataRefreshFlow()"></a><a name="getDataRefreshFlow--"></a><a name="setDataRefreshFlow--"></a>
<h3 class="api-name" id="dataRefreshFlow()">dataRefreshFlow</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/kotlin/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a><br>val&nbsp;<a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#dataRefreshFlow()">dataRefreshFlow</a>:&nbsp;@<a href="/reference/kotlin/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a>&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>&gt;</pre>
<aside class="caution"><strong>This property is deprecated.</strong><br>dataRefreshFlow is now redundant with the information passed from loadStateFlow and getItemCount, and will be removed in a future alpha version</aside>
<p>A <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a></code> of <code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a></code> that is emitted when new <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> generations are submitted and displayed. The <code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a></code> that is emitted is <code>true</code> if the new <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> is empty, <code>false</code> otherwise.</p>
</div>
<div><a name="getItemCount()"></a><a name="setItemCount()"></a><a name="getItemCount--"></a><a name="setItemCount--"></a>
<h3 class="api-name" id="itemCount()">itemCount</h3>
<pre class="api-signature no-pretty-print">val&nbsp;<a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#itemCount()">itemCount</a>:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a></pre>
<p>Get the number of items currently presented by this Differ. This value can be directly returned to <a href="[androidx.recyclerview.widget.RecyclerView.Adapter.getItemCount]">androidx.recyclerview.widget.RecyclerView.Adapter.getItemCount</a>.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a></code></td>
<td width="100%">
<p>Number of items being presented.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="getLoadStateFlow()"></a><a name="setLoadStateFlow()"></a><a name="getLoadStateFlow--"></a><a name="setLoadStateFlow--"></a>
<h3 class="api-name" id="loadStateFlow()">loadStateFlow</h3>
<pre class="api-signature no-pretty-print">@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-opt-in/index.html">OptIn</a>(markerClass&nbsp;=&nbsp;[FlowPreview])<br>val&nbsp;<a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#loadStateFlow()">loadStateFlow</a>:&nbsp;@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-opt-in/index.html">OptIn</a>(markerClass&nbsp;=&nbsp;[FlowPreview])&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a>&lt;<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>&gt;</pre>
<p>A hot <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a></code> of <code><a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> that emits a snapshot whenever the loading state of the current <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> changes.</p>
<p>This flow is conflated, so it buffers the last update to <code><a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> and immediately delivers the current load states on collection.</p>
</div>
<h2>Public constructors</h2>
<div><a name="AsyncPagingDataDiffer(DiffUtil.ItemCallback&lt;T&gt;, ListUpdateCallback, kotlinx.coroutines.CoroutineDispatcher, kotlinx.coroutines.CoroutineDispatcher)"></a><a name="AsyncPagingDataDiffer-DiffUtil.ItemCallback&lt;T&gt;-ListUpdateCallback-kotlinx.coroutines.CoroutineDispatcher-kotlinx.coroutines.CoroutineDispatcher-"></a>
<h3 class="api-name" id="AsyncPagingDataDiffer(DiffUtil.ItemCallback&lt;T&gt;,ListUpdateCallback,kotlinx.coroutines.CoroutineDispatcher,kotlinx.coroutines.CoroutineDispatcher)">AsyncPagingDataDiffer</h3>
<pre class="api-signature no-pretty-print">&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#AsyncPagingDataDiffer(DiffUtil.ItemCallback&lt;T&gt;,ListUpdateCallback,kotlinx.coroutines.CoroutineDispatcher,kotlinx.coroutines.CoroutineDispatcher)">AsyncPagingDataDiffer</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;diffCallback:&nbsp;<a href="/reference/kotlin/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;T&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;updateCallback:&nbsp;<a href="/reference/kotlin/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;mainDispatcher:&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html">CoroutineDispatcher</a> = Dispatchers.Main,<br>&nbsp;&nbsp;&nbsp;&nbsp;workerDispatcher:&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html">CoroutineDispatcher</a> = Dispatchers.Default<br>)</pre>
</div>
<h2>Public functions</h2>
<div><a name="addDataRefreshListener-kotlin.Function1-"></a>
<h3 class="api-name" id="addDataRefreshListener(kotlin.Function1)">addDataRefreshListener</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/kotlin/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a><br>fun&nbsp;<span><del><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#addDataRefreshListener(kotlin.Function1)">addDataRefreshListener</a></del></span>(listener:&nbsp;(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>):&nbsp;@<a href="/reference/kotlin/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></pre>
<aside class="caution"><strong>This function is deprecated.</strong><br>dataRefreshListener is now redundant with the information passed from loadStateListener and getItemCount, and will be removed in a future alpha version</aside>
<p>Add a listener to observe new <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> generations.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>listener:&nbsp;(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
<td width="100%">
<p>called whenever a new <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> is submitted and displayed. <code>true</code> is passed to the <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#listener()">listener</a></code> if the new <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> is empty, <code>false</code> otherwise.</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/AsyncPagingDataDiffer.html#removeDataRefreshListener(kotlin.Function1)">removeDataRefreshListener</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="addLoadStateListener-kotlin.Function1-"></a>
<h3 class="api-name" id="addLoadStateListener(kotlin.Function1)">addLoadStateListener</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;<a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#addLoadStateListener(kotlin.Function1)">addLoadStateListener</a>(listener:&nbsp;(<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>):&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></pre>
<p>Add a <code><a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> listener to observe the loading state of the current <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code>.</p>
<p>As new <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> generations are submitted and displayed, the listener will be notified to reflect the current <code><a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code>.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>listener:&nbsp;(<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
<td width="100%">
<p><code><a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a></code> listener to receive updates.</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/AsyncPagingDataDiffer.html#removeLoadStateListener(kotlin.Function1)">removeLoadStateListener</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="getItem-kotlin.Int-"></a>
<h3 class="api-name" id="getItem(kotlin.Int)">getItem</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;<a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#getItem(kotlin.Int)">getItem</a>(@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/-int-range/index.html">IntRange</a>&nbsp;index:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a>):&nbsp;T?</pre>
<p>Get the item from the current PagedList at the specified index.</p>
<p>Note that this operates on both loaded items and null padding within the PagedList.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>T?</code></td>
<td width="100%">
<p>The item, or <code>null</code>, if a <code>null</code> placeholder is at the specified position.</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>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/-int-range/index.html">IntRange</a>&nbsp;index:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a></code></td>
<td width="100%">
<p>Index of item to get, must be &gt;= 0, and &lt; <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#itemCount()">itemCount</a></code></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="peek-kotlin.Int-"></a>
<h3 class="api-name" id="peek(kotlin.Int)">peek</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;<a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#peek(kotlin.Int)">peek</a>(@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/-int-range/index.html">IntRange</a>&nbsp;index:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a>):&nbsp;T?</pre>
<p>Returns the presented item at the specified position, without notifying Paging of the item access that would normally trigger page loads.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>T?</code></td>
<td width="100%">
<p>The presented item at position <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#index()">index</a></code>, <code>null</code> if it is a placeholder</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>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/-int-range/index.html">IntRange</a>&nbsp;index:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a></code></td>
<td width="100%">
<p>Index of the presented item to return, including placeholders.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="refresh--"></a>
<h3 class="api-name" id="refresh()">refresh</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;<a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a>():&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></pre>
<p>Refresh the data presented by this <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html">AsyncPagingDataDiffer</a></code>.</p>
<p><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a></code> triggers the creation of a new <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> with a new instance of <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> to represent an updated snapshot of the backing dataset. If a <code><a href="/reference/kotlin/androidx/paging/RemoteMediator.html">RemoteMediator</a></code> is set, calling <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a></code> will also trigger a call to <code><a href="/reference/kotlin/androidx/paging/RemoteMediator.html#load(androidx.paging.LoadType,androidx.paging.PagingState)">RemoteMediator.load</a></code> with <code><a href="/reference/kotlin/androidx/paging/LoadType.REFRESH.html">LoadType</a></code> to allow <code><a href="/reference/kotlin/androidx/paging/RemoteMediator.html">RemoteMediator</a></code> to check for updates to the dataset backing <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code>.</p>
<p>Note: This API is intended for UI-driven refresh signals, such as swipe-to-refresh. Invalidation due repository-layer signals, such as DB-updates, should instead use <code><a href="/reference/kotlin/androidx/paging/PagingSource.html#invalidate()">PagingSource.invalidate</a></code>.</p>
<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/PagingSource.html#invalidate()">invalidate</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="removeDataRefreshListener-kotlin.Function1-"></a>
<h3 class="api-name" id="removeDataRefreshListener(kotlin.Function1)">removeDataRefreshListener</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/kotlin/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a><br>fun&nbsp;<span><del><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#removeDataRefreshListener(kotlin.Function1)">removeDataRefreshListener</a></del></span>(listener:&nbsp;(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>):&nbsp;@<a href="/reference/kotlin/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></pre>
<aside class="caution"><strong>This function is deprecated.</strong><br>dataRefreshListener is now redundant with the information passed from loadStateListener and getItemCount, and will be removed in a future alpha version</aside>
<p>Remove a previously registered listener for new <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> generations.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>listener:&nbsp;(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
<td width="100%">
<p>Previously registered listener.</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/AsyncPagingDataDiffer.html#addDataRefreshListener(kotlin.Function1)">addDataRefreshListener</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="removeLoadStateListener-kotlin.Function1-"></a>
<h3 class="api-name" id="removeLoadStateListener(kotlin.Function1)">removeLoadStateListener</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;<a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#removeLoadStateListener(kotlin.Function1)">removeLoadStateListener</a>(listener:&nbsp;(<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>):&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></pre>
<p>Remove a previously registered <code><a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> listener.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>listener:&nbsp;(<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>)&nbsp;-&gt;&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
<td width="100%">
<p>Previously registered listener.</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/AsyncPagingDataDiffer.html#addLoadStateListener(kotlin.Function1)">addLoadStateListener</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="retry--"></a>
<h3 class="api-name" id="retry()">retry</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;<a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#retry()">retry</a>():&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></pre>
<p>Retry any failed load requests that would result in a <code><a href="/reference/kotlin/androidx/paging/LoadState.Error.html">LoadState.Error</a></code> update to this <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html">AsyncPagingDataDiffer</a></code>.</p>
<p>Unlike <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a></code>, this does not invalidate <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code>, it only retries failed loads within the same generation of <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code>.</p>
<p><code><a href="/reference/kotlin/androidx/paging/LoadState.Error.html">LoadState.Error</a></code> can be generated from two types of load requests:</p>
<ul>
<li>
<p><code><a href="/reference/kotlin/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">PagingSource.load</a></code> returning <code><a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Error.html">PagingSource.LoadResult.Error</a></code></p>
</li>
<li>
<p><code><a href="/reference/kotlin/androidx/paging/RemoteMediator.html#load(androidx.paging.LoadType,androidx.paging.PagingState)">RemoteMediator.load</a></code> returning <code><a href="/reference/kotlin/androidx/paging/RemoteMediator.MediatorResult.Error.html">RemoteMediator.MediatorResult.Error</a></code></p>
</li>
</ul>
</div>
<div><a name="snapshot--"></a>
<h3 class="api-name" id="snapshot()">snapshot</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;<a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#snapshot()">snapshot</a>():&nbsp;<a href="/reference/kotlin/androidx/paging/ItemSnapshotList.html">ItemSnapshotList</a>&lt;T&gt;</pre>
<p>Returns a new <code><a href="/reference/kotlin/androidx/paging/ItemSnapshotList.html">ItemSnapshotList</a></code> representing the currently presented items, including any placeholders if they are enabled.</p>
</div>
<div><a name="submitData-androidx.paging.PagingData-"></a>
<h3 class="api-name" id="submitData(androidx.paging.PagingData)">submitData</h3>
<pre class="api-signature no-pretty-print">suspend&nbsp;fun&nbsp;<a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a>(pagingData:&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;):&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></pre>
<p>Present a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> until it is invalidated by a call to <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a></code> or <code><a href="/reference/kotlin/androidx/paging/PagingSource.html#invalidate()">PagingSource.invalidate</a></code>.</p>
<p><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code> should be called on the same <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html">CoroutineDispatcher</a></code> where updates will be dispatched to UI, typically <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-main.html">Dispatchers.Main</a></code>. (this is done for you if you use <code>lifecycleScope.launch {}</code>).</p>
<p>This method is typically used when collecting from a <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a></code> produced by <code><a href="/reference/kotlin/androidx/paging/Pager.html">Pager</a></code>. For RxJava or LiveData support, use the non-suspending overload of <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code>, which accepts a <a href="[Lifecycle]">Lifecycle</a>.</p>
<p>Note: This method suspends while it is actively presenting page loads from a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code>, until the <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> is invalidated. Although cancellation will propagate to this call automatically, collecting from a <code><a href="/reference/kotlin/androidx/paging/Pager.html#flow()">Pager.flow</a></code> with the intention of presenting the most up-to-date representation of your backing dataset should typically be done using <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/index.html">collectLatest</a></code>.</p>
<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/Pager.html">Pager</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="submitData(Lifecycle, androidx.paging.PagingData)"></a><a name="submitData-Lifecycle-androidx.paging.PagingData-"></a>
<h3 class="api-name" id="submitData(Lifecycle,androidx.paging.PagingData)">submitData</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;<a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(Lifecycle,androidx.paging.PagingData)">submitData</a>(lifecycle:&nbsp;<a href="/reference/kotlin/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>,&nbsp;pagingData:&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;):&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></pre>
<p>Present a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> until it is either invalidated or another call to <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code> is made.</p>
<p>This method is typically used when observing a RxJava or LiveData stream produced by <code><a href="/reference/kotlin/androidx/paging/Pager.html">Pager</a></code>. For <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a></code> support, use the suspending overload of <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code>, which automates cancellation via <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html">CoroutineScope</a></code> instead of relying of <a href="[Lifecycle]">Lifecycle</a>.</p>
<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/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code></td>
<td width="100%"></td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/Pager.html">Pager</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>