| <html devsite="true"> |
| <head> |
| <title>PagingLiveDataKt</title> |
| {% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} |
| {% include "_shared/_reference-head-tags.html" %} |
| </head> |
| <body> |
| <h1>PagingLiveDataKt</h1> |
| {% setvar page_path %}androidx/paging/PagingLiveDataKt.html{% endsetvar %} |
| {% setvar can_switch %}1{% endsetvar %} |
| {% include "reference/_java_switcher2.md" %} |
| <p> |
| <pre>public final class PagingLiveDataKt</pre> |
| </p> |
| <hr> |
| <h2>Summary</h2> |
| <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 <a href="/reference/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a><<a href="/reference/androidx/paging/PagingData.html">PagingData</a><Value>></code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/androidx/paging/package-summary.html#liveData(androidx.paging.Pager)">liveData</a></code></div> |
| <p>A LiveData of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code>, which mirrors the stream provided by <code><a href="/reference/androidx/paging/Pager.html#flow()">Pager.flow</a></code>, but exposes it as a LiveData.</p> |
| </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>static final <a href="/reference/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a></code></td> |
| <td width="100%"> |
| <div><code><T extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>> <a href="/reference/androidx/paging/PagingLiveDataKt.html#cachedIn(LiveData<PagingData<T>>,Lifecycle)">cachedIn</a>(<br> <a href="/reference/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a><<a href="/reference/androidx/paging/PagingData.html">PagingData</a><T>> receiver,<br> <a href="/reference/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a> lifecycle<br>)</code></div> |
| <p>Operator which caches a LiveData of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> within the scope of a Lifecycle.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>static final <a href="/reference/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a></code></td> |
| <td width="100%"> |
| <div><code><T extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>> <a href="/reference/androidx/paging/PagingLiveDataKt.html#cachedIn(LiveData<PagingData<T>>,kotlinx.coroutines.CoroutineScope)">cachedIn</a>(<br> <a href="/reference/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a><<a href="/reference/androidx/paging/PagingData.html">PagingData</a><T>> receiver,<br> <a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html">CoroutineScope</a> scope<br>)</code></div> |
| <p>Operator which caches a LiveData of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> within a <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html">CoroutineScope</a></code>.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <h2>Public fields</h2> |
| <div><a name="getLiveData(androidx.paging.Pager)"></a><a name="setLiveData(androidx.paging.Pager)"></a><a name="getLiveData-androidx.paging.Pager-"></a><a name="setLiveData-androidx.paging.Pager-"></a> |
| <h3 class="api-name" id="liveData(androidx.paging.Pager)">liveData</h3> |
| <pre class="api-signature no-pretty-print">public final <a href="/reference/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a><<a href="/reference/androidx/paging/PagingData.html">PagingData</a><Value>> <a href="/reference/androidx/paging/package-summary.html#liveData(androidx.paging.Pager)">liveData</a></pre> |
| <p>A <a href="[LiveData]">LiveData</a> of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code>, which mirrors the stream provided by <code><a href="/reference/androidx/paging/Pager.html#flow()">Pager.flow</a></code>, but exposes it as a <a href="[LiveData]">LiveData</a>.</p> |
| </div> |
| <h2>Public methods</h2> |
| <div><a name="cachedIn(LiveData<PagingData<T>>, Lifecycle)"></a><a name="cachedIn-LiveData<PagingData<T>>-Lifecycle-"></a> |
| <h3 class="api-name" id="cachedIn(LiveData<PagingData<T>>,Lifecycle)">cachedIn</h3> |
| <pre class="api-signature no-pretty-print">public static final <a href="/reference/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a> <T extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>> <a href="/reference/androidx/paging/PagingLiveDataKt.html#cachedIn(LiveData<PagingData<T>>,Lifecycle)">cachedIn</a>(<br> <a href="/reference/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a><<a href="/reference/androidx/paging/PagingData.html">PagingData</a><T>> receiver,<br> <a href="/reference/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a> lifecycle<br>)</pre> |
| <p>Operator which caches a <a href="[LiveData]">LiveData</a> of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> within the scope of a <a href="[Lifecycle]">Lifecycle</a>.</p> |
| <p><code><a href="/reference/androidx/paging/package-summary.html#cachedIn(kotlinx.coroutines.flow.Flow,kotlinx.coroutines.CoroutineScope)">cachedIn</a></code> multicasts pages loaded and transformed by a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code>, allowing multiple observers on the same instance of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> to receive the same events, avoiding redundant work, but comes at the cost of buffering those events in memory.</p> |
| <p>Calling <code><a href="/reference/androidx/paging/package-summary.html#cachedIn(kotlinx.coroutines.flow.Flow,kotlinx.coroutines.CoroutineScope)">cachedIn</a></code> is required to allow calling <a href="[androidx.paging.AsyncPagingDataAdapter]">androidx.paging.AsyncPagingDataAdapter</a> on the same instance of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> emitted by <code><a href="/reference/androidx/paging/Pager.html">Pager</a></code> or any of its transformed derivatives, as reloading data from scratch on the same generation of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> is an unsupported operation.</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/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a> lifecycle</code></td> |
| <td width="100%"> |
| <p>The <a href="[Lifecycle]">Lifecycle</a> where the page cache will be kept alive.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div><a name="cachedIn(LiveData<PagingData<T>>, kotlinx.coroutines.CoroutineScope)"></a><a name="cachedIn-LiveData<PagingData<T>>-kotlinx.coroutines.CoroutineScope-"></a> |
| <h3 class="api-name" id="cachedIn(LiveData<PagingData<T>>,kotlinx.coroutines.CoroutineScope)">cachedIn</h3> |
| <pre class="api-signature no-pretty-print">public static final <a href="/reference/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a> <T extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>> <a href="/reference/androidx/paging/PagingLiveDataKt.html#cachedIn(LiveData<PagingData<T>>,kotlinx.coroutines.CoroutineScope)">cachedIn</a>(<br> <a href="/reference/[JVM root]/<ERROR CLASS>.html"><ERROR CLASS></a><<a href="/reference/androidx/paging/PagingData.html">PagingData</a><T>> receiver,<br> <a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html">CoroutineScope</a> scope<br>)</pre> |
| <p>Operator which caches a <a href="[LiveData]">LiveData</a> of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> within a <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html">CoroutineScope</a></code>.</p> |
| <p><code><a href="/reference/androidx/paging/package-summary.html#cachedIn(kotlinx.coroutines.flow.Flow,kotlinx.coroutines.CoroutineScope)">cachedIn</a></code> multicasts pages loaded and transformed by a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code>, allowing multiple observers on the same instance of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> to receive the same events, avoiding redundant work, but comes at the cost of buffering those events in memory.</p> |
| <p>Calling <code><a href="/reference/androidx/paging/package-summary.html#cachedIn(kotlinx.coroutines.flow.Flow,kotlinx.coroutines.CoroutineScope)">cachedIn</a></code> is required to allow calling <a href="[androidx.paging.AsyncPagingDataAdapter]">androidx.paging.AsyncPagingDataAdapter</a> on the same instance of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> emitted by <code><a href="/reference/androidx/paging/Pager.html">Pager</a></code> or any of its transformed derivatives, as reloading data from scratch on the same generation of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> is an unsupported operation.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Parameters</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html">CoroutineScope</a> scope</code></td> |
| <td width="100%"> |
| <p>The <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html">CoroutineScope</a></code> where the page cache will be kept alive. Typically this would be a managed scope such as <code>ViewModel.viewModelScope</code>, which automatically cancels after the <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> stream is no longer needed. Otherwise, the provided <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html">CoroutineScope</a></code> must be manually cancelled to avoid memory leaks.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| </body> |
| </html> |