| <html devsite="true"> |
| <head> |
| <title>PagingSource</title> |
| {% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} |
| {% include "_shared/_reference-head-tags.html" %} |
| </head> |
| <body> |
| <h1>PagingSource</h1> |
| {% setvar page_path %}androidx/paging/PagingSource.html{% endsetvar %} |
| {% setvar can_switch %}1{% endsetvar %} |
| {% include "reference/_java_switcher2.md" %} |
| <p> |
| <pre>public abstract class PagingSource<Key extends <a href="/reference/java/lang/Object.html">Object</a>, Value extends <a href="/reference/java/lang/Object.html">Object</a>></pre> |
| </p> |
| <div class="devsite-table-wrapper"><devsite-expandable><span class="expand-control jd-sumtable-subclasses">Known direct subclasses |
| <div class="showalways" id="subclasses-direct"><a href="/reference/androidx/paging/ListenableFuturePagingSource.html">ListenableFuturePagingSource</a>, <a href="/reference/androidx/paging/rxjava2/RxPagingSource.html">RxPagingSource</a>, <a href="/reference/androidx/paging/rxjava3/RxPagingSource.html">RxPagingSource</a></div> |
| </span> |
| <div id="subclasses-direct-summary"> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <tbody> |
| <tr> |
| <td><code><a href="/reference/androidx/paging/ListenableFuturePagingSource.html">ListenableFuturePagingSource</a></code></td> |
| <td width="100%"> |
| <p>ListenableFuture-based compatibility wrapper around <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>'s suspending APIs.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/androidx/paging/rxjava2/RxPagingSource.html">RxPagingSource</a></code></td> |
| <td width="100%"> |
| <p>Rx-based compatibility wrapper around <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>'s suspending APIs.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/androidx/paging/rxjava3/RxPagingSource.html">RxPagingSource</a></code></td> |
| <td width="100%"> |
| <p>Rx-based compatibility wrapper around <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>'s suspending APIs.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| </devsite-expandable> </div> |
| <hr> |
| <p>Base class for an abstraction of pageable static data from some source, where loading pages of data is typically an expensive operation. Some examples of common <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>s might be from network or from a database.</p> |
| <p>An instance of a <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> is used to load pages of data for an instance of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code>.</p> |
| <p>A <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> can grow as it loads more data, but the data loaded cannot be updated. If the underlying data set is modified, a new <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> / <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> pair must be created to represent an updated snapshot of the data.</p> |
| <h3> Loading Pages</h3> |
| <p><code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> queries data from its <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> in response to loading hints generated as the user scrolls in a <code>RecyclerView</code>.</p> |
| <p>To control how and when a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> queries data from its <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>, see <code><a href="/reference/androidx/paging/PagingConfig.html">PagingConfig</a></code>, which defines behavior such as <code><a href="/reference/androidx/paging/PagingConfig.html#pageSize()">PagingConfig.pageSize</a></code> and <code><a href="/reference/androidx/paging/PagingConfig.html#prefetchDistance()">PagingConfig.prefetchDistance</a></code>.</p> |
| <h3> Updating Data</h3> |
| <p>A <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> / <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> pair is a snapshot of the data set. A new <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> / <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> must be created if an update occurs, such as a reorder, insert, delete, or content update occurs. A <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> must detect that it cannot continue loading its snapshot (for instance, when Database query notices a table being invalidated), and call <code><a href="/reference/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code>. Then a new <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> / <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> pair would be created to represent data from the new state of the database query.</p> |
| <h3> Presenting Data to UI</h3> |
| <p>To present data loaded by a <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> to a <code>RecyclerView</code>, create an instance of <code><a href="/reference/androidx/paging/Pager.html">Pager</a></code>, which provides a stream of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> that you may collect from and submit to a <code><a href="/reference/androidx/paging/PagingDataAdapter.html">PagingDataAdapter</a></code>.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Parameters</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code><Key extends <a href="/reference/java/lang/Object.html">Object</a>></code></td> |
| <td width="100%"> |
| <p>Type of key which define what data to load. E.g. <code><a href="/reference/kotlin/Int.html">Int</a></code> to represent either a page number or item position, or <code><a href="/reference/kotlin/String.html">String</a></code> if your network uses Strings as next tokens returned with each response.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><Value extends <a href="/reference/java/lang/Object.html">Object</a>></code></td> |
| <td width="100%"> |
| <p>Type of data loaded in by this <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>. E.g., the type of data that will be passed to a <code><a href="/reference/androidx/paging/PagingDataAdapter.html">PagingDataAdapter</a></code> to be displayed in a <code>RecyclerView</code>.</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/androidx/paging/Pager.html">Pager</a></code></td> |
| <td width="100%"></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <h2>Summary</h2> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2"><h3>Nested types</h3></th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code><a href="/reference/androidx/paging/PagingSource.LoadParams.html">PagingSource.LoadParams</a></code></td> |
| <td width="100%"> |
| <p>Params for a load request on a <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> from <code><a href="/reference/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">PagingSource.load</a></code>.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/androidx/paging/PagingSource.LoadParams.Append.html">PagingSource.LoadParams.Append</a></code></td> |
| <td width="100%"> |
| <p>Params to load a page of data from a <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> via <code><a href="/reference/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">PagingSource.load</a></code> to be appended to the end of the list.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/androidx/paging/PagingSource.LoadParams.Prepend.html">PagingSource.LoadParams.Prepend</a></code></td> |
| <td width="100%"> |
| <p>Params to load a page of data from a <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> via <code><a href="/reference/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">PagingSource.load</a></code> to be prepended to the start of the list.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/androidx/paging/PagingSource.LoadParams.Refresh.html">PagingSource.LoadParams.Refresh</a></code></td> |
| <td width="100%"> |
| <p>Params for an initial load request on a <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> from <code><a href="/reference/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">PagingSource.load</a></code> or a refresh triggered by <code><a href="/reference/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code>.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/androidx/paging/PagingSource.LoadResult.html">PagingSource.LoadResult</a></code></td> |
| <td width="100%"> |
| <p>Result of a load request from <code><a href="/reference/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">PagingSource.load</a></code>.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/androidx/paging/PagingSource.LoadResult.Error.html">PagingSource.LoadResult.Error</a></code></td> |
| <td width="100%"> |
| <p>Error result object for <code><a href="/reference/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">PagingSource.load</a></code>.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/androidx/paging/PagingSource.LoadResult.Page.html">PagingSource.LoadResult.Page</a></code></td> |
| <td width="100%"> |
| <p>Success result object for <code><a href="/reference/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">PagingSource.load</a></code>.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/androidx/paging/PagingSource.LoadResult.Page.Companion.html">PagingSource.LoadResult.Page.Companion</a></code></td> |
| <td width="100%"></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2"><h3>Public fields</h3></th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code>final boolean</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/androidx/paging/PagingSource.html#invalid()">invalid</a></code></div> |
| <p>Whether this <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> has been invalidated, which should happen when the data this <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> represents changes since it was first instantiated.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>boolean</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/androidx/paging/PagingSource.html#jumpingSupported()">jumpingSupported</a></code></div> |
| <p><code>true</code> if this <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> supports jumping, <code>false</code> otherwise.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>boolean</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/androidx/paging/PagingSource.html#keyReuseSupported()">keyReuseSupported</a></code></div> |
| <p><code>true</code> if this <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> expects to re-use keys to load distinct pages without a call to <code><a href="/reference/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code>, <code>false</code> otherwise.</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><Key extends <a href="/reference/java/lang/Object.html">Object</a>, Value extends <a href="/reference/java/lang/Object.html">Object</a>> <a href="/reference/androidx/paging/PagingSource.html#PagingSource()">PagingSource</a>()</code></div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2"><h3>Public methods</h3></th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code>Key</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/androidx/paging/PagingSource.html#getRefreshKey(androidx.paging.PagingState)">getRefreshKey</a>(<a href="/reference/androidx/paging/PagingState.html">PagingState</a><Key, Value> state)</code></div> |
| <p>Request a refresh key given the current <code><a href="/reference/androidx/paging/PagingState.html">PagingState</a></code> of the associated <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> used to present loaded data from this <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>void</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/androidx/paging/PagingSource.html#invalidate()">invalidate</a>()</code></div> |
| <p>Signal the <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> to stop loading.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>abstract <a href="/reference/androidx/paging/PagingSource.LoadResult.html">PagingSource.LoadResult</a><Key, Value></code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">load</a>(<a href="/reference/androidx/paging/PagingSource.LoadParams.html">PagingSource.LoadParams</a><Key> params)</code></div> |
| <p>Loading API for <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>final void</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/androidx/paging/PagingSource.html#registerInvalidatedCallback(kotlin.Function0)">registerInvalidatedCallback</a>(<a href="/reference/kotlin/jvm/functions/Function0.html">Function0</a><<a href="/reference/kotlin/Unit.html">Unit</a>> onInvalidatedCallback)</code></div> |
| <p>Add a callback to invoke when the <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> is first invalidated.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>final void</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/androidx/paging/PagingSource.html#unregisterInvalidatedCallback(kotlin.Function0)">unregisterInvalidatedCallback</a>(<a href="/reference/kotlin/jvm/functions/Function0.html">Function0</a><<a href="/reference/kotlin/Unit.html">Unit</a>> onInvalidatedCallback)</code></div> |
| <p>Remove a previously added invalidate callback.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <h2>Public fields</h2> |
| <div><a name="getInvalid()"></a><a name="setInvalid()"></a><a name="getInvalid--"></a><a name="setInvalid--"></a> |
| <h3 class="api-name" id="invalid()">invalid</h3> |
| <pre class="api-signature no-pretty-print">public final boolean <a href="/reference/androidx/paging/PagingSource.html#invalid()">invalid</a></pre> |
| <p>Whether this <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> has been invalidated, which should happen when the data this <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> represents changes since it was first instantiated.</p> |
| </div> |
| <div><a name="getJumpingSupported()"></a><a name="setJumpingSupported()"></a><a name="getJumpingSupported--"></a><a name="setJumpingSupported--"></a> |
| <h3 class="api-name" id="jumpingSupported()">jumpingSupported</h3> |
| <pre class="api-signature no-pretty-print">public boolean <a href="/reference/androidx/paging/PagingSource.html#jumpingSupported()">jumpingSupported</a></pre> |
| <p><code>true</code> if this <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> supports jumping, <code>false</code> otherwise.</p> |
| <p>Override this to <code>true</code> if pseudo-fast scrolling via jumps is supported.</p> |
| <p>A jump occurs when a <code>RecyclerView</code> scrolls through a number of placeholders defined by <code><a href="/reference/androidx/paging/PagingConfig.html#jumpThreshold()">PagingConfig.jumpThreshold</a></code> and triggers a load with <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType</a></code>.</p> |
| <p><code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>s that support jumps should override <code><a href="/reference/androidx/paging/PagingSource.html#getRefreshKey(androidx.paging.PagingState)">getRefreshKey</a></code> to return a <code><a href="/reference/androidx/paging/PagingSource.html">Key</a></code> that would load data fulfilling the viewport given a user's current <code><a href="/reference/androidx/paging/PagingState.html#anchorPosition()">PagingState.anchorPosition</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/androidx/paging/PagingConfig.html#jumpThreshold()">jumpThreshold</a></code></td> |
| <td width="100%"></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div><a name="getKeyReuseSupported()"></a><a name="setKeyReuseSupported()"></a><a name="getKeyReuseSupported--"></a><a name="setKeyReuseSupported--"></a> |
| <h3 class="api-name" id="keyReuseSupported()">keyReuseSupported</h3> |
| <pre class="api-signature no-pretty-print">public boolean <a href="/reference/androidx/paging/PagingSource.html#keyReuseSupported()">keyReuseSupported</a></pre> |
| <p><code>true</code> if this <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> expects to re-use keys to load distinct pages without a call to <code><a href="/reference/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code>, <code>false</code> otherwise.</p> |
| </div> |
| <h2>Public constructors</h2> |
| <div><a name="PagingSource--"></a> |
| <h3 class="api-name" id="PagingSource()">PagingSource</h3> |
| <pre class="api-signature no-pretty-print">public final <Key extends <a href="/reference/java/lang/Object.html">Object</a>, Value extends <a href="/reference/java/lang/Object.html">Object</a>> <a href="/reference/androidx/paging/PagingSource.html#PagingSource()">PagingSource</a>()</pre> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Parameters</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code><Key extends <a href="/reference/java/lang/Object.html">Object</a>></code></td> |
| <td width="100%"> |
| <p>Type of key which define what data to load. E.g. <code><a href="/reference/kotlin/Int.html">Int</a></code> to represent either a page number or item position, or <code><a href="/reference/kotlin/String.html">String</a></code> if your network uses Strings as next tokens returned with each response.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><Value extends <a href="/reference/java/lang/Object.html">Object</a>></code></td> |
| <td width="100%"> |
| <p>Type of data loaded in by this <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>. E.g., the type of data that will be passed to a <code><a href="/reference/androidx/paging/PagingDataAdapter.html">PagingDataAdapter</a></code> to be displayed in a <code>RecyclerView</code>.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <h2>Public methods</h2> |
| <div><a name="getRefreshKey-androidx.paging.PagingState-"></a> |
| <h3 class="api-name" id="getRefreshKey(androidx.paging.PagingState)">getRefreshKey</h3> |
| <pre class="api-signature no-pretty-print">@<a href="/reference/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a><br>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a><br>public Key <a href="/reference/androidx/paging/PagingSource.html#getRefreshKey(androidx.paging.PagingState)">getRefreshKey</a>(<a href="/reference/androidx/paging/PagingState.html">PagingState</a><Key, Value> state)</pre> |
| <p>Request a refresh key given the current <code><a href="/reference/androidx/paging/PagingState.html">PagingState</a></code> of the associated <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> used to present loaded data from this <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>.</p> |
| <p>The <code><a href="/reference/androidx/paging/PagingSource.html">Key</a></code> returned by this method is used to populate the <code><a href="/reference/androidx/paging/PagingSource.LoadParams.html#key()">LoadParams.key</a></code> for load requests of type <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">REFRESH</a></code>.</p> |
| <p>For example, if items are loaded based on position, and keys are positions, <code><a href="/reference/androidx/paging/PagingSource.html#getRefreshKey(androidx.paging.PagingState)">getRefreshKey</a></code> should return the position of the item.</p> |
| <p>Alternately, if items contain a key used to load, get the key from the item in the page at index <code><a href="/reference/androidx/paging/PagingState.html#anchorPosition()">PagingState.anchorPosition</a></code>.</p> |
| <p>If this operation cannot be supported (generally, because keys cannot be reused across refresh) return <code>null</code> - this is the default behavior.</p> |
| <p>Note: This method is guaranteed to only be called if the initial load succeeds and the list of loaded pages is not empty. In the case where a refresh is triggered before the initial load succeeds or it errors out, the initial key passed to <code><a href="/reference/androidx/paging/Pager.html">Pager</a></code> will be used.</p> |
| </div> |
| <div><a name="invalidate--"></a> |
| <h3 class="api-name" id="invalidate()">invalidate</h3> |
| <pre class="api-signature no-pretty-print">public void <a href="/reference/androidx/paging/PagingSource.html#invalidate()">invalidate</a>()</pre> |
| <p>Signal the <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> to stop loading.</p> |
| <p>This method is idempotent. i.e., If <code><a href="/reference/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code> has already been called, subsequent calls to this method should have no effect.</p> |
| </div> |
| <div><a name="load-androidx.paging.PagingSource.LoadParams-"></a> |
| <h3 class="api-name" id="load(androidx.paging.PagingSource.LoadParams)">load</h3> |
| <pre class="api-signature no-pretty-print">public abstract <a href="/reference/androidx/paging/PagingSource.LoadResult.html">PagingSource.LoadResult</a><Key, Value> <a href="/reference/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">load</a>(<a href="/reference/androidx/paging/PagingSource.LoadParams.html">PagingSource.LoadParams</a><Key> params)</pre> |
| <p>Loading API for <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>.</p> |
| <p>Implement this method to trigger your async load (e.g. from database or network).</p> |
| </div> |
| <div><a name="registerInvalidatedCallback-kotlin.Function0-"></a> |
| <h3 class="api-name" id="registerInvalidatedCallback(kotlin.Function0)">registerInvalidatedCallback</h3> |
| <pre class="api-signature no-pretty-print">public final void <a href="/reference/androidx/paging/PagingSource.html#registerInvalidatedCallback(kotlin.Function0)">registerInvalidatedCallback</a>(<a href="/reference/kotlin/jvm/functions/Function0.html">Function0</a><<a href="/reference/kotlin/Unit.html">Unit</a>> onInvalidatedCallback)</pre> |
| <p>Add a callback to invoke when the <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> is first invalidated.</p> |
| <p>Once invalidated, a <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> will not become valid again.</p> |
| <p>A <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> will only invoke its callbacks once - the first time <code><a href="/reference/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code> is called, on that thread.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Parameters</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code><a href="/reference/kotlin/jvm/functions/Function0.html">Function0</a><<a href="/reference/kotlin/Unit.html">Unit</a>> onInvalidatedCallback</code></td> |
| <td width="100%"> |
| <p>The callback that will be invoked on thread that invalidates the <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div><a name="unregisterInvalidatedCallback-kotlin.Function0-"></a> |
| <h3 class="api-name" id="unregisterInvalidatedCallback(kotlin.Function0)">unregisterInvalidatedCallback</h3> |
| <pre class="api-signature no-pretty-print">public final void <a href="/reference/androidx/paging/PagingSource.html#unregisterInvalidatedCallback(kotlin.Function0)">unregisterInvalidatedCallback</a>(<a href="/reference/kotlin/jvm/functions/Function0.html">Function0</a><<a href="/reference/kotlin/Unit.html">Unit</a>> onInvalidatedCallback)</pre> |
| <p>Remove a previously added invalidate callback.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Parameters</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code><a href="/reference/kotlin/jvm/functions/Function0.html">Function0</a><<a href="/reference/kotlin/Unit.html">Unit</a>> onInvalidatedCallback</code></td> |
| <td width="100%"> |
| <p>The previously added callback.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| </body> |
| </html> |