| <html devsite="true"> |
| <head> |
| <title>AsyncPagingDataDiffer</title> |
| {% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %} |
| {% include "_shared/_reference-head-tags.html" %} |
| </head> |
| <body> |
| <div id="metadata-info-block"> |
| <div id="source-link"><a href="https://cs.android.com/search?q=file:androidx/paging/AsyncPagingDataDiffer.kt+class:androidx.paging.AsyncPagingDataDiffer&ss=androidx/platform/frameworks/support" class="external">View Source</a></div> |
| </div> |
| <h1>AsyncPagingDataDiffer</h1> |
| <p> |
| <pre>class <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html">AsyncPagingDataDiffer</a><T : <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>></pre> |
| </p> |
| <hr> |
| <p>Helper class for mapping a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> into a <code><a href="/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter.html">RecyclerView.Adapter</a></code>.</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"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Public constructors</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td> |
| <div><code><T : <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>> <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#AsyncPagingDataDiffer(androidx.recyclerview.widget.DiffUtil.ItemCallback,androidx.recyclerview.widget.ListUpdateCallback,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext)">AsyncPagingDataDiffer</a>(<br> diffCallback: <a href="/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback.html">DiffUtil.ItemCallback</a><T>,<br> updateCallback: <a href="/reference/kotlin/androidx/recyclerview/widget/ListUpdateCallback.html">ListUpdateCallback</a>,<br> mainDispatcher: <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/-coroutine-context/index.html">CoroutineContext</a>,<br> workerDispatcher: <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/-coroutine-context/index.html">CoroutineContext</a><br>)</code></div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Public functions</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td> |
| <td> |
| <div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#addLoadStateListener(kotlin.Function1)">addLoadStateListener</a>(listener: (<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>) <span style="white-space: nowrap;">-></span> <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><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td> |
| <td> |
| <div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#addOnPagesUpdatedListener(kotlin.Function0)">addOnPagesUpdatedListener</a>(listener: () <span style="white-space: nowrap;">-></span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>)</code></div> |
| <p>Add a listener which triggers after the pages presented to the UI are updated, even if the actual items presented don't change.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>T?</code></td> |
| <td> |
| <div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#getItem(kotlin.Int)">getItem</a>(index: @<a href="/reference/kotlin/androidx/annotation/IntRange.html">IntRange</a>(from = 0) <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> |
| <div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#peek(kotlin.Int)">peek</a>(index: @<a href="/reference/kotlin/androidx/annotation/IntRange.html">IntRange</a>(from = 0) <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> |
| <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="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td> |
| <td> |
| <div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#removeLoadStateListener(kotlin.Function1)">removeLoadStateListener</a>(listener: (<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>) <span style="white-space: nowrap;">-></span> <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> |
| <div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#removeOnPagesUpdatedListener(kotlin.Function0)">removeOnPagesUpdatedListener</a>(listener: () <span style="white-space: nowrap;">-></span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>)</code></div> |
| <p>Remove a previously registered listener for new <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> generations completing initial load and presenting to the UI.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td> |
| <td> |
| <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><T></code></td> |
| <td> |
| <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> |
| <div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a>(pagingData: <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a><T>)</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> |
| <div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.lifecycle.Lifecycle,androidx.paging.PagingData)">submitData</a>(lifecycle: <a href="/reference/kotlin/androidx/lifecycle/Lifecycle.html">Lifecycle</a>, pagingData: <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a><T>)</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> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Public properties</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a></code></td> |
| <td> |
| <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://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a><<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>></code></td> |
| <td> |
| <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> |
| <tr> |
| <td><code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a><<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>></code></td> |
| <td> |
| <div><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#onPagesUpdatedFlow()">onPagesUpdatedFlow</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> that emits after the pages presented to the UI are updated, even if the actual items presented don't change.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="list"> |
| <h2>Public constructors</h2> |
| <div class="api-item"><a name="AsyncPagingDataDiffer(androidx.recyclerview.widget.DiffUtil.ItemCallback, androidx.recyclerview.widget.ListUpdateCallback, kotlin.coroutines.CoroutineContext, kotlin.coroutines.CoroutineContext)"></a><a name="AsyncPagingDataDiffer-androidx.recyclerview.widget.DiffUtil.ItemCallback-androidx.recyclerview.widget.ListUpdateCallback-kotlin.coroutines.CoroutineContext-kotlin.coroutines.CoroutineContext-"></a><a name="asyncpagingdatadiffer"></a> |
| <h3 class="api-name" id="AsyncPagingDataDiffer(androidx.recyclerview.widget.DiffUtil.ItemCallback,androidx.recyclerview.widget.ListUpdateCallback,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext)">AsyncPagingDataDiffer</h3> |
| <pre class="api-signature no-pretty-print"><T : <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>> <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#AsyncPagingDataDiffer(androidx.recyclerview.widget.DiffUtil.ItemCallback,androidx.recyclerview.widget.ListUpdateCallback,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext)">AsyncPagingDataDiffer</a>(<br> diffCallback: <a href="/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback.html">DiffUtil.ItemCallback</a><T>,<br> updateCallback: <a href="/reference/kotlin/androidx/recyclerview/widget/ListUpdateCallback.html">ListUpdateCallback</a>,<br> mainDispatcher: <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/-coroutine-context/index.html">CoroutineContext</a> = Dispatchers.Main,<br> workerDispatcher: <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/-coroutine-context/index.html">CoroutineContext</a> = Dispatchers.Default<br>)</pre> |
| </div> |
| </div> |
| <div class="list"> |
| <h2>Public functions</h2> |
| <div class="api-item"><a name="addLoadStateListener-kotlin.Function1-"></a><a name="addloadstatelistener"></a> |
| <h3 class="api-name" id="addLoadStateListener(kotlin.Function1)">addLoadStateListener</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#addLoadStateListener(kotlin.Function1)">addLoadStateListener</a>(listener: (<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>) <span style="white-space: nowrap;">-></span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>): <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> |
| <pre class="prettyprint">val adapter = UserPagingAdapter() |
| adapter.addLoadStateListener { |
| // show a retry button outside the list when refresh hits an error |
| retryButton.isVisible = it.refresh is LoadState.Error |
| |
| // swipeRefreshLayout displays whether refresh is occurring |
| swipeRefreshLayout.isRefreshing = it.refresh is LoadState.Loading |
| |
| // show an empty state over the list when loading initially, before items are loaded |
| emptyState.isVisible = it.refresh is LoadState.Loading && adapter.itemCount == 0 |
| }</pre> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Parameters</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>listener: (<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>) <span style="white-space: nowrap;">-></span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td> |
| <td> |
| <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"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">See also</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#removeLoadStateListener(kotlin.Function1)">removeLoadStateListener</a></code></td> |
| <td></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div class="api-item"><a name="addOnPagesUpdatedListener-kotlin.Function0-"></a><a name="addonpagesupdatedlistener"></a> |
| <h3 class="api-name" id="addOnPagesUpdatedListener(kotlin.Function0)">addOnPagesUpdatedListener</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#addOnPagesUpdatedListener(kotlin.Function0)">addOnPagesUpdatedListener</a>(listener: () <span style="white-space: nowrap;">-></span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>): <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></pre> |
| <p>Add a listener which triggers after the pages presented to the UI are updated, even if the actual items presented don't change.</p> |
| <p>An update is triggered from one of the following:</p> |
| <ul> |
| <li> |
| <p><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code> is called and initial load completes, regardless of any differences in the loaded data</p> |
| </li> |
| <li> |
| <p>A <code><a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page.html">Page</a></code> is inserted</p> |
| </li> |
| <li> |
| <p>A <code><a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page.html">Page</a></code> is dropped</p> |
| </li> |
| </ul> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Parameters</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>listener: () <span style="white-space: nowrap;">-></span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td> |
| <td> |
| <p>called after pages presented are updated.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">See also</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#removeOnPagesUpdatedListener(kotlin.Function0)">removeOnPagesUpdatedListener</a></code></td> |
| <td></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div class="api-item"><a name="getItem-kotlin.Int-"></a><a name="getitem"></a> |
| <h3 class="api-name" id="getItem(kotlin.Int)">getItem</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#getItem(kotlin.Int)">getItem</a>(index: @<a href="/reference/kotlin/androidx/annotation/IntRange.html">IntRange</a>(from = 0) <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a>): 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"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Parameters</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>index: @<a href="/reference/kotlin/androidx/annotation/IntRange.html">IntRange</a>(from = 0) <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a></code></td> |
| <td> |
| <p>Index of item to get, must be >= 0, and <<code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#itemCount()">itemCount</a></code></p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Returns</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>T?</code></td> |
| <td> |
| <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> |
| <div class="api-item"><a name="peek-kotlin.Int-"></a><a name="peek"></a> |
| <h3 class="api-name" id="peek(kotlin.Int)">peek</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#peek(kotlin.Int)">peek</a>(index: @<a href="/reference/kotlin/androidx/annotation/IntRange.html">IntRange</a>(from = 0) <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a>): 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"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Parameters</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>index: @<a href="/reference/kotlin/androidx/annotation/IntRange.html">IntRange</a>(from = 0) <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a></code></td> |
| <td> |
| <p>Index of the presented item to return, including placeholders.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Returns</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>T?</code></td> |
| <td> |
| <p>The presented item at position <code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#peek(kotlin.Int)">index</a></code>, <code>null</code> if it is a placeholder</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div class="api-item"><a name="refresh--"></a><a name="refresh"></a> |
| <h3 class="api-name" id="refresh()">refresh</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a>(): <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.html#REFRESH">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> |
| <pre class="prettyprint">class MyActivity : AppCompatActivity() { |
| private lateinit var binding: MyActivityBinding |
| private val pagingAdapter = UserPagingAdapter() |
| |
| override fun onCreate(savedInstanceState: Bundle?) { |
| super.onCreate(savedInstanceState) |
| binding = MyActivityBinding.inflate(layoutInflater) |
| setContentView(binding.root) |
| |
| binding.recyclerView.adapter = pagingAdapter |
| pagingAdapter.addLoadStateListener { loadStates -> |
| binding.swipeRefreshLayout.isRefreshing = loadStates.refresh is LoadState.Loading |
| } |
| |
| binding.swipeRefreshLayout.setOnRefreshListener { |
| pagingAdapter.refresh() |
| } |
| } |
| }</pre> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">See also</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="/reference/kotlin/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code></td> |
| <td></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div class="api-item"><a name="removeLoadStateListener-kotlin.Function1-"></a><a name="removeloadstatelistener"></a> |
| <h3 class="api-name" id="removeLoadStateListener(kotlin.Function1)">removeLoadStateListener</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#removeLoadStateListener(kotlin.Function1)">removeLoadStateListener</a>(listener: (<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>) <span style="white-space: nowrap;">-></span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>): <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"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Parameters</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>listener: (<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>) <span style="white-space: nowrap;">-></span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td> |
| <td> |
| <p>Previously registered listener.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">See also</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#addLoadStateListener(kotlin.Function1)">addLoadStateListener</a></code></td> |
| <td></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div class="api-item"><a name="removeOnPagesUpdatedListener-kotlin.Function0-"></a><a name="removeonpagesupdatedlistener"></a> |
| <h3 class="api-name" id="removeOnPagesUpdatedListener(kotlin.Function0)">removeOnPagesUpdatedListener</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#removeOnPagesUpdatedListener(kotlin.Function0)">removeOnPagesUpdatedListener</a>(listener: () <span style="white-space: nowrap;">-></span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>): <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></pre> |
| <p>Remove a previously registered listener for new <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> generations completing initial load and presenting to the UI.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Parameters</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>listener: () <span style="white-space: nowrap;">-></span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td> |
| <td> |
| <p>Previously registered listener.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">See also</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#addOnPagesUpdatedListener(kotlin.Function0)">addOnPagesUpdatedListener</a></code></td> |
| <td></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div class="api-item"><a name="retry--"></a><a name="retry"></a> |
| <h3 class="api-name" id="retry()">retry</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#retry()">retry</a>(): <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 class="api-item"><a name="snapshot--"></a><a name="snapshot"></a> |
| <h3 class="api-name" id="snapshot()">snapshot</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#snapshot()">snapshot</a>(): <a href="/reference/kotlin/androidx/paging/ItemSnapshotList.html">ItemSnapshotList</a><T></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 class="api-item"><a name="submitData-androidx.paging.PagingData-"></a><a name="submitdata"></a> |
| <h3 class="api-name" id="submitData(androidx.paging.PagingData)">submitData</h3> |
| <pre class="api-signature no-pretty-print">suspend fun <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a>(pagingData: <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a><T>): <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>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 <code><a href="/reference/kotlin/androidx/lifecycle/Lifecycle.html">Lifecycle</a></code>.</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"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">See also</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="/reference/kotlin/androidx/paging/Pager.html">Pager</a></code></td> |
| <td></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div class="api-item"><a name="submitData(androidx.lifecycle.Lifecycle, androidx.paging.PagingData)"></a><a name="submitData-androidx.lifecycle.Lifecycle-androidx.paging.PagingData-"></a><a name="submitdata"></a> |
| <h3 class="api-name" id="submitData(androidx.lifecycle.Lifecycle,androidx.paging.PagingData)">submitData</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.lifecycle.Lifecycle,androidx.paging.PagingData)">submitData</a>(lifecycle: <a href="/reference/kotlin/androidx/lifecycle/Lifecycle.html">Lifecycle</a>, pagingData: <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a><T>): <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 <code><a href="/reference/kotlin/androidx/lifecycle/Lifecycle.html">Lifecycle</a></code>.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">See also</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code></td> |
| <td></td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/kotlin/androidx/paging/Pager.html">Pager</a></code></td> |
| <td></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| </div> |
| <div class="list"> |
| <h2>Public properties</h2> |
| <div class="api-item"><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 <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#itemCount()">itemCount</a>: <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 <code><a href="/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter.html#getItemCount()">androidx.recyclerview.widget.RecyclerView.Adapter.getItemCount</a></code>.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Returns</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a></code></td> |
| <td> |
| <p>Number of items being presented, including placeholders.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div class="api-item"><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">val <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#loadStateFlow()">loadStateFlow</a>: <a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a><<a href="/reference/kotlin/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>></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> |
| <pre class="prettyprint">val adapter = UserPagingAdapter() |
| lifecycleScope.launch { |
| adapter.loadStateFlow |
| .map { it.refresh } |
| .distinctUntilChanged() |
| .collectLatest { |
| // show a retry button outside the list when refresh hits an error |
| retryButton.isVisible = it is LoadState.Error |
| |
| // swipeRefreshLayout displays whether refresh is occurring |
| swipeRefreshLayout.isRefreshing = it is LoadState.Loading |
| |
| // show an empty state over the list when loading initially, before items are loaded |
| emptyState.isVisible = it is LoadState.Loading && adapter.itemCount == 0 |
| } |
| }</pre> |
| </div> |
| <div class="api-item"><a name="getOnPagesUpdatedFlow()"></a><a name="setOnPagesUpdatedFlow()"></a><a name="getOnPagesUpdatedFlow--"></a><a name="setOnPagesUpdatedFlow--"></a> |
| <h3 class="api-name" id="onPagesUpdatedFlow()">onPagesUpdatedFlow</h3> |
| <pre class="api-signature no-pretty-print">val <a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#onPagesUpdatedFlow()">onPagesUpdatedFlow</a>: <a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a><<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>></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> that emits after the pages presented to the UI are updated, even if the actual items presented don't change.</p> |
| <p>An update is triggered from one of the following:</p> |
| <ul> |
| <li> |
| <p><code><a href="/reference/kotlin/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code> is called and initial load completes, regardless of any differences in the loaded data</p> |
| </li> |
| <li> |
| <p>A <code><a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page.html">Page</a></code> is inserted</p> |
| </li> |
| <li> |
| <p>A <code><a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page.html">Page</a></code> is dropped</p> |
| </li> |
| </ul> |
| <p>Note: This is a <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-shared-flow/index.html">SharedFlow</a></code> configured to replay 0 items with a buffer of size 64. If a collector lags behind page updates, it may trigger multiple times for each intermediate update that was presented while your collector was still working. To avoid this behavior, you can <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/index.html">conflate</a></code> this <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a></code> so that you only receive the latest update, which is useful in cases where you are simply updating UI and don't care about tracking the exact number of page updates.</p> |
| </div> |
| </div> |
| </body> |
| </html> |