blob: 732a405e55b6e082f0b33aa0207981d2b34c1d61 [file] [log] [blame]
Alex Saveaue60da312020-09-09 23:34:43 +00001<html devsite="true">
2 <head>
3 <title>PagingSource</title>
4{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %}
5{% include "_shared/_reference-head-tags.html" %}
6 </head>
7 <body>
8 <h1>PagingSource</h1>
9{% setvar page_path %}androidx/paging/PagingSource.html{% endsetvar %}
10{% setvar can_switch %}1{% endsetvar %}
11{% include "reference/_kotlin_switcher2.md" %}
12 <p>TODO(b/166518424) class signature</p>
13 <p>TODO(b/166518951) inheritance hierarchy</p>
14 <p>TODO(b/166518636) direct subclasses</p>
15 <p>TODO(b/166518636) indirect subclasses</p>
16 <hr>
Alex Saveaufe9fe472020-09-10 01:41:31 +000017 <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/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code>s might be from network or from a database.</p>
18 <p>An instance of a <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> is used to load pages of data for an instance of <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code>.</p>
19 <p>A <code><a href="/reference/kotlin/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/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> / <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> pair must be created to represent an updated snapshot of the data.</p>
20 <h3> Loading Pages</h3>
21 <p><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> queries data from its <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> in response to loading hints generated as the user scrolls in a <code>RecyclerView</code>.</p>
22 <p>To control how and when a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> queries data from its <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code>, see <code><a href="/reference/kotlin/androidx/paging/PagingConfig.html">PagingConfig</a></code>, which defines behavior such as <code><a href="/reference/kotlin/androidx/paging/PagingConfig.html#pageSize()">pageSize</a></code> and <code><a href="/reference/kotlin/androidx/paging/PagingConfig.html#prefetchDistance()">prefetchDistance</a></code>.</p>
23 <h3> Updating Data</h3>
24 <p>A <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> / <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> pair is a snapshot of the data set. A new <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> / <code><a href="/reference/kotlin/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/kotlin/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/kotlin/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code>. Then a new <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> / <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> pair would be created to represent data from the new state of the database query.</p>
25 <h3> Presenting Data to UI</h3>
26 <p>To present data loaded by a <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> to a <code>RecyclerView</code>, create an instance of <code><a href="/reference/kotlin/androidx/paging/Pager.html">Pager</a></code>, which provides a stream of <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> that you may collect from and submit to a <code><a href="/reference/kotlin/androidx/paging/PagingDataAdapter.html">PagingDataAdapter</a></code>.</p>
Alex Saveaue60da312020-09-09 23:34:43 +000027 <div class="devsite-table-wrapper">
28 <table class="responsive">
29 <thead>
30 <tr>
31 <th colspan="2">Parameters</th>
32 </tr>
33 </thead>
34 <tbody>
35 <tr>
36 <td><code>Key</code></td>
37 <td width="100%">
38 <p>Type of key which define what data to load. E.g. <code><a href="/reference/kotlin/kotlin/Int.html">Int</a></code> to represent either a page number or item position, or <code><a href="/reference/kotlin/kotlin/String.html">String</a></code> if your network uses Strings as next tokens returned with each response.</p>
39 </td>
40 </tr>
41 <tr>
42 <td><code>Value</code></td>
43 <td width="100%">
Alex Saveaufe9fe472020-09-10 01:41:31 +000044 <p>Type of data loaded in by this <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code>. E.g., the type of data that will be passed to a <code><a href="/reference/kotlin/androidx/paging/PagingDataAdapter.html">PagingDataAdapter</a></code> to be displayed in a <code>RecyclerView</code>.</p>
Alex Saveaue60da312020-09-09 23:34:43 +000045 </td>
46 </tr>
47 </tbody>
48 </table>
49 </div>
50 <div class="devsite-table-wrapper">
51 <table class="responsive">
52 <thead>
53 <tr>
54 <th colspan="2">See also</th>
55 </tr>
56 </thead>
57 <tbody>
58 <tr>
59 <td><code><a href="/reference/kotlin/androidx/paging/Pager.html">Pager</a></code></td>
60 <td width="100%">
61 <p></p>
62 </td>
63 </tr>
64 </tbody>
65 </table>
66 </div>
67 <h2>Summary</h2>
68 <p>Nested *</p>
69 <p>Enum values</p>
Alex Saveaue60da312020-09-09 23:34:43 +000070 <div class="devsite-table-wrapper">
71 <table class="responsive">
72 <thead>
73 <tr>
Alex Saveau65f73172020-09-09 22:46:21 +000074 <th colspan="2"><h3>Public properties</h3></th>
75 </tr>
76 </thead>
77 <tbody>
78 <tr>
Alex Saveau5c56aab2020-09-11 20:30:44 +000079 <td><code><a href="/reference/kotlin/kotlin/Boolean.html">Boolean</a></code></td>
Alex Saveau65f73172020-09-09 22:46:21 +000080 <td width="100%">
81 <div><code><a href="/reference/kotlin/androidx/paging/PagingSource.html#invalid()">invalid</a></code></div>
82 <p>Whether this <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> has been invalidated, which should happen when the data this <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> represents changes since it was first instantiated.</p>
83 </td>
84 </tr>
85 <tr>
86 <td><code>open <a href="/reference/kotlin/kotlin/Boolean.html">Boolean</a></code></td>
87 <td width="100%">
88 <div><code><a href="/reference/kotlin/androidx/paging/PagingSource.html#jumpingSupported()">jumpingSupported</a></code></div>
Alex Saveaufe9fe472020-09-10 01:41:31 +000089 <p><code>true</code> if this <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> supports jumping, <code>false</code> otherwise.</p>
Alex Saveau65f73172020-09-09 22:46:21 +000090 </td>
91 </tr>
92 <tr>
93 <td><code>open <a href="/reference/kotlin/kotlin/Boolean.html">Boolean</a></code></td>
94 <td width="100%">
95 <div><code><a href="/reference/kotlin/androidx/paging/PagingSource.html#keyReuseSupported()">keyReuseSupported</a></code></div>
96 <p><code>true</code> if this <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> expects to re-use keys to load distinct pages without a call to <code><a href="/reference/kotlin/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code>, <code>false</code> otherwise.</p>
97 </td>
98 </tr>
99 </tbody>
100 </table>
101 </div>
102 <div class="devsite-table-wrapper">
103 <table class="responsive">
104 <thead>
105 <tr>
Alex Saveauf393e9a2020-09-17 21:15:59 +0000106 <th colspan="2"><h3>Public constructors</h3></th>
107 </tr>
108 </thead>
109 <tbody>
110 <tr>
111 <td>
112 <div><code><a href="/reference/kotlin/androidx/paging/PagingSource.html#PagingSource()">PagingSource</a>()</code></div>
113 </td>
114 </tr>
115 </tbody>
116 </table>
117 </div>
118 <div class="devsite-table-wrapper">
119 <table class="responsive">
120 <thead>
121 <tr>
Alex Saveaue60da312020-09-09 23:34:43 +0000122 <th colspan="2"><h3>Public functions</h3></th>
123 </tr>
124 </thead>
125 <tbody>
126 <tr>
Alex Saveau3b6f5402020-09-16 05:44:58 +0000127 <td><code>open Key</code></td>
Alex Saveaue60da312020-09-09 23:34:43 +0000128 <td width="100%">
129 <div><code><a href="/reference/kotlin/androidx/paging/PagingSource.html#getRefreshKey(androidx.paging.PagingState)">getRefreshKey</a>(state:&nbsp;<a href="/reference/kotlin/androidx/paging/PagingState.html">PagingState</a>&lt;Key,&nbsp;Value&gt;)</code></div>
Alex Saveaufe9fe472020-09-10 01:41:31 +0000130 <p>Request a refresh key given the current <code><a href="/reference/kotlin/androidx/paging/PagingState.html">PagingState</a></code> of the associated <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> used to present loaded data from this <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code>.</p>
Alex Saveaue60da312020-09-09 23:34:43 +0000131 </td>
132 </tr>
133 <tr>
Alex Saveau02907a92020-09-10 00:50:30 +0000134 <td><code>open <a href="/reference/kotlin/kotlin/Unit.html">Unit</a></code></td>
Alex Saveaue60da312020-09-09 23:34:43 +0000135 <td width="100%">
136 <div><code><a href="/reference/kotlin/androidx/paging/PagingSource.html#invalidate()">invalidate</a>()</code></div>
Alex Saveaufe9fe472020-09-10 01:41:31 +0000137 <p>Signal the <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> to stop loading.</p>
Alex Saveaue60da312020-09-09 23:34:43 +0000138 </td>
139 </tr>
140 <tr>
Alex Saveau02907a92020-09-10 00:50:30 +0000141 <td><code>suspend&nbsp;abstract <a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.html">PagingSource.LoadResult</a>&lt;Key,&nbsp;Value&gt;</code></td>
Alex Saveaue60da312020-09-09 23:34:43 +0000142 <td width="100%">
143 <div><code><a href="/reference/kotlin/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">load</a>(params:&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.LoadParams.html">PagingSource.LoadParams</a>&lt;Key&gt;)</code></div>
Alex Saveaufe9fe472020-09-10 01:41:31 +0000144 <p>Loading API for <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code>.</p>
Alex Saveaue60da312020-09-09 23:34:43 +0000145 </td>
146 </tr>
147 <tr>
Alex Saveau5c56aab2020-09-11 20:30:44 +0000148 <td><code><a href="/reference/kotlin/kotlin/Unit.html">Unit</a></code></td>
Alex Saveaue60da312020-09-09 23:34:43 +0000149 <td width="100%">
Alex Saveau33d4a2d2020-09-18 01:03:22 +0000150 <div><code><a href="/reference/kotlin/androidx/paging/PagingSource.html#registerInvalidatedCallback(kotlin.Function0)">registerInvalidatedCallback</a>(onInvalidatedCallback:&nbsp;()&nbsp;-&gt;&nbsp;<a href="/reference/kotlin/kotlin/Unit.html">Unit</a>)</code></div>
Alex Saveaufe9fe472020-09-10 01:41:31 +0000151 <p>Add a callback to invoke when the <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> is first invalidated.</p>
Alex Saveaue60da312020-09-09 23:34:43 +0000152 </td>
153 </tr>
154 <tr>
Alex Saveau5c56aab2020-09-11 20:30:44 +0000155 <td><code><a href="/reference/kotlin/kotlin/Unit.html">Unit</a></code></td>
Alex Saveaue60da312020-09-09 23:34:43 +0000156 <td width="100%">
Alex Saveau33d4a2d2020-09-18 01:03:22 +0000157 <div><code><a href="/reference/kotlin/androidx/paging/PagingSource.html#unregisterInvalidatedCallback(kotlin.Function0)">unregisterInvalidatedCallback</a>(onInvalidatedCallback:&nbsp;()&nbsp;-&gt;&nbsp;<a href="/reference/kotlin/kotlin/Unit.html">Unit</a>)</code></div>
Alex Saveaufe9fe472020-09-10 01:41:31 +0000158 <p>Remove a previously added invalidate callback.</p>
Alex Saveaue60da312020-09-09 23:34:43 +0000159 </td>
160 </tr>
161 </tbody>
162 </table>
163 </div>
Alex Saveau65f73172020-09-09 22:46:21 +0000164 <h2>Public properties</h2>
165 <div><a name="getInvalid()"></a><a name="setInvalid()"></a><a name="getInvalid--"></a><a name="setInvalid--"></a>
166 <h3 class="api-name" id="invalid()">invalid</h3>
Alex Saveau35de4362020-09-12 02:12:48 +0000167 <pre class="api-signature no-pretty-print">val&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.html#invalid()">invalid</a>:&nbsp;<a href="/reference/kotlin/kotlin/Boolean.html">Boolean</a></pre>
Alex Saveau65f73172020-09-09 22:46:21 +0000168 <p>Whether this <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> has been invalidated, which should happen when the data this <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> represents changes since it was first instantiated.</p>
169 </div>
170 <div><a name="getJumpingSupported()"></a><a name="setJumpingSupported()"></a><a name="getJumpingSupported--"></a><a name="setJumpingSupported--"></a>
171 <h3 class="api-name" id="jumpingSupported()">jumpingSupported</h3>
Alex Saveau35de4362020-09-12 02:12:48 +0000172 <pre class="api-signature no-pretty-print">open&nbsp;val&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.html#jumpingSupported()">jumpingSupported</a>:&nbsp;<a href="/reference/kotlin/kotlin/Boolean.html">Boolean</a></pre>
Alex Saveaufe9fe472020-09-10 01:41:31 +0000173 <p><code>true</code> if this <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> supports jumping, <code>false</code> otherwise.</p>
174 <p>Override this to <code>true</code> if pseudo-fast scrolling via jumps is supported.</p>
175 <p>A jump occurs when a <code>RecyclerView</code> scrolls through a number of placeholders defined by <code><a href="/reference/kotlin/androidx/paging/PagingConfig.html#jumpThreshold()">jumpThreshold</a></code> and triggers a load with <code><a href="/reference/kotlin/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code>.</p>
176 <p><code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code>s that support jumps should override <code><a href="/reference/kotlin/androidx/paging/PagingSource.html#getRefreshKey(androidx.paging.PagingState)">getRefreshKey</a></code> to return a <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> that would load data fulfilling the viewport given a user's current <code><a href="/reference/kotlin/androidx/paging/PagingState.html#anchorPosition()">anchorPosition</a></code>.</p>
Alex Saveau65f73172020-09-09 22:46:21 +0000177 <div class="devsite-table-wrapper">
178 <table class="responsive">
179 <thead>
180 <tr>
181 <th colspan="2">See also</th>
182 </tr>
183 </thead>
184 <tbody>
185 <tr>
186 <td><code><a href="/reference/kotlin/androidx/paging/PagingConfig.html#jumpThreshold()">jumpThreshold</a></code></td>
187 <td width="100%">
188 <p></p>
189 </td>
190 </tr>
191 </tbody>
192 </table>
193 </div>
194 </div>
195 <div><a name="getKeyReuseSupported()"></a><a name="setKeyReuseSupported()"></a><a name="getKeyReuseSupported--"></a><a name="setKeyReuseSupported--"></a>
196 <h3 class="api-name" id="keyReuseSupported()">keyReuseSupported</h3>
Alex Saveau35de4362020-09-12 02:12:48 +0000197 <pre class="api-signature no-pretty-print">open&nbsp;val&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.html#keyReuseSupported()">keyReuseSupported</a>:&nbsp;<a href="/reference/kotlin/kotlin/Boolean.html">Boolean</a></pre>
Alex Saveau65f73172020-09-09 22:46:21 +0000198 <p><code>true</code> if this <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> expects to re-use keys to load distinct pages without a call to <code><a href="/reference/kotlin/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code>, <code>false</code> otherwise.</p>
199 </div>
Alex Saveauf393e9a2020-09-17 21:15:59 +0000200 <h2>Public constructors</h2>
201 <div><a name="PagingSource--"></a>
202 <h3 class="api-name" id="PagingSource()">PagingSource</h3>
203 <pre class="api-signature no-pretty-print">fun&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.html#PagingSource()">PagingSource</a>():&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a>&lt;Key,&nbsp;Value&gt;</pre>
204 <div class="devsite-table-wrapper">
205 <table class="responsive">
206 <thead>
207 <tr>
208 <th colspan="2">Parameters</th>
209 </tr>
210 </thead>
211 <tbody>
212 <tr>
213 <td><code>Key</code></td>
214 <td width="100%">
215 <p>Type of key which define what data to load. E.g. <code><a href="/reference/kotlin/kotlin/Int.html">Int</a></code> to represent either a page number or item position, or <code><a href="/reference/kotlin/kotlin/String.html">String</a></code> if your network uses Strings as next tokens returned with each response.</p>
216 </td>
217 </tr>
218 <tr>
219 <td><code>Value</code></td>
220 <td width="100%">
221 <p>Type of data loaded in by this <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code>. E.g., the type of data that will be passed to a <code><a href="/reference/kotlin/androidx/paging/PagingDataAdapter.html">PagingDataAdapter</a></code> to be displayed in a <code>RecyclerView</code>.</p>
222 </td>
223 </tr>
224 </tbody>
225 </table>
226 </div>
227 </div>
Alex Saveaue60da312020-09-09 23:34:43 +0000228 <h2>Public functions</h2>
229 <div><a name="getRefreshKey-androidx.paging.PagingState-"></a>
230 <h3 class="api-name" id="getRefreshKey(androidx.paging.PagingState)">getRefreshKey</h3>
Alex Saveau3b6f5402020-09-16 05:44:58 +0000231 <pre class="api-signature no-pretty-print">@<a href="/reference/kotlin/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a><br>open&nbsp;fun&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.html#getRefreshKey(androidx.paging.PagingState)">getRefreshKey</a>(state:&nbsp;<a href="/reference/kotlin/androidx/paging/PagingState.html">PagingState</a>&lt;Key,&nbsp;Value&gt;):&nbsp;Key</pre>
Alex Saveaufe9fe472020-09-10 01:41:31 +0000232 <p>Request a refresh key given the current <code><a href="/reference/kotlin/androidx/paging/PagingState.html">PagingState</a></code> of the associated <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> used to present loaded data from this <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code>.</p>
233 <p>The <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> returned by this method is used to populate the <code><a href="/reference/kotlin/androidx/paging/PagingSource.LoadParams.html#key()">key</a></code> for load requests of type <code><a href="/reference/kotlin/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code>.</p>
234 <p>For example, if items are loaded based on position, and keys are positions, <code><a href="/reference/kotlin/androidx/paging/PagingSource.html#getRefreshKey(androidx.paging.PagingState)">getRefreshKey</a></code> should return the position of the item.</p>
235 <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/kotlin/androidx/paging/PagingState.html#anchorPosition()">anchorPosition</a></code>.</p>
236 <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>
237 <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/kotlin/androidx/paging/Pager.html">Pager</a></code> will be used.</p>
Alex Saveaue60da312020-09-09 23:34:43 +0000238 </div>
239 <div><a name="invalidate--"></a>
240 <h3 class="api-name" id="invalidate()">invalidate</h3>
Alex Saveau35de4362020-09-12 02:12:48 +0000241 <pre class="api-signature no-pretty-print">open&nbsp;fun&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.html#invalidate()">invalidate</a>():&nbsp;<a href="/reference/kotlin/kotlin/Unit.html">Unit</a></pre>
Alex Saveaufe9fe472020-09-10 01:41:31 +0000242 <p>Signal the <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> to stop loading.</p>
243 <p>This method is idempotent. i.e., If <code><a href="/reference/kotlin/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code> has already been called, subsequent calls to this method should have no effect.</p>
Alex Saveaue60da312020-09-09 23:34:43 +0000244 </div>
245 <div><a name="load-androidx.paging.PagingSource.LoadParams-"></a>
246 <h3 class="api-name" id="load(androidx.paging.PagingSource.LoadParams)">load</h3>
Alex Saveau35de4362020-09-12 02:12:48 +0000247 <pre class="api-signature no-pretty-print">suspend&nbsp;abstract&nbsp;fun&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">load</a>(params:&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.LoadParams.html">PagingSource.LoadParams</a>&lt;Key&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.html">PagingSource.LoadResult</a>&lt;Key,&nbsp;Value&gt;</pre>
Alex Saveaufe9fe472020-09-10 01:41:31 +0000248 <p>Loading API for <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code>.</p>
249 <p>Implement this method to trigger your async load (e.g. from database or network).</p>
Alex Saveaue60da312020-09-09 23:34:43 +0000250 </div>
251 <div><a name="registerInvalidatedCallback-kotlin.Function0-"></a>
252 <h3 class="api-name" id="registerInvalidatedCallback(kotlin.Function0)">registerInvalidatedCallback</h3>
Alex Saveau33d4a2d2020-09-18 01:03:22 +0000253 <pre class="api-signature no-pretty-print">fun&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.html#registerInvalidatedCallback(kotlin.Function0)">registerInvalidatedCallback</a>(onInvalidatedCallback:&nbsp;()&nbsp;-&gt;&nbsp;<a href="/reference/kotlin/kotlin/Unit.html">Unit</a>):&nbsp;<a href="/reference/kotlin/kotlin/Unit.html">Unit</a></pre>
Alex Saveaufe9fe472020-09-10 01:41:31 +0000254 <p>Add a callback to invoke when the <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> is first invalidated.</p>
255 <p>Once invalidated, a <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> will not become valid again.</p>
256 <p>A <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> will only invoke its callbacks once - the first time <code><a href="/reference/kotlin/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code> is called, on that thread.</p>
Alex Saveaue60da312020-09-09 23:34:43 +0000257 <div class="devsite-table-wrapper">
258 <table class="responsive">
259 <thead>
260 <tr>
261 <th colspan="2">Parameters</th>
262 </tr>
263 </thead>
264 <tbody>
265 <tr>
266 <td><code>onInvalidatedCallback</code></td>
267 <td width="100%">
268 <p>The callback that will be invoked on thread that invalidates the <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code>.</p>
269 </td>
270 </tr>
271 </tbody>
272 </table>
273 </div>
274 </div>
275 <div><a name="unregisterInvalidatedCallback-kotlin.Function0-"></a>
276 <h3 class="api-name" id="unregisterInvalidatedCallback(kotlin.Function0)">unregisterInvalidatedCallback</h3>
Alex Saveau33d4a2d2020-09-18 01:03:22 +0000277 <pre class="api-signature no-pretty-print">fun&nbsp;<a href="/reference/kotlin/androidx/paging/PagingSource.html#unregisterInvalidatedCallback(kotlin.Function0)">unregisterInvalidatedCallback</a>(onInvalidatedCallback:&nbsp;()&nbsp;-&gt;&nbsp;<a href="/reference/kotlin/kotlin/Unit.html">Unit</a>):&nbsp;<a href="/reference/kotlin/kotlin/Unit.html">Unit</a></pre>
Alex Saveaufe9fe472020-09-10 01:41:31 +0000278 <p>Remove a previously added invalidate callback.</p>
Alex Saveaue60da312020-09-09 23:34:43 +0000279 <div class="devsite-table-wrapper">
280 <table class="responsive">
281 <thead>
282 <tr>
283 <th colspan="2">Parameters</th>
284 </tr>
285 </thead>
286 <tbody>
287 <tr>
288 <td><code>onInvalidatedCallback</code></td>
289 <td width="100%">
290 <p>The previously added callback.</p>
291 </td>
292 </tr>
293 </tbody>
294 </table>
295 </div>
296 </div>
297 </body>
298</html>