blob: 74e6bff42cfc1edf3693a162b8df016e687d8012 [file] [log] [blame]
<html devsite="true">
<head>
<title>PagingData</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/PagingData.kt+class:androidx.paging.PagingData&amp;ss=androidx/platform/frameworks/support" class="external">View Source</a></div>
</div>
<h1>PagingData</h1>
<p>
<pre>class <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt;</pre>
</p>
<hr>
<p>Container for Paged data from a single generation of loads.</p>
<p>Each refresh of data (generally either pushed by local storage, or pulled from the network) will have a separate corresponding <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code>.</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 companion functions</h3></th>
</tr>
</thead>
<tbody class="list">
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.Companion.html#empty()">empty</a>()</code></div>
<p>Create a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> that immediately displays an empty list of items without dispatching any load state updates when submitted to a presenter.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.Companion.html#empty(androidx.paging.LoadStates,androidx.paging.LoadStates)">empty</a>(sourceLoadStates:&nbsp;<a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a>,&nbsp;mediatorLoadStates:&nbsp;<a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a>?)</code></div>
<p>Create a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> that immediately displays an empty list of items when submitted to a presenter.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.Companion.html#from(kotlin.collections.List)">from</a>(data:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;T&gt;)</code></div>
<p>Create a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> that immediately displays a static list of items without dispatching any load state updates when submitted to a presenter.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.Companion.html#from(kotlin.collections.List,androidx.paging.LoadStates,androidx.paging.LoadStates)">from</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;data:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;T&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;sourceLoadStates:&nbsp;<a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;mediatorLoadStates:&nbsp;<a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a>?<br>)</code></div>
<p>Create a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> that immediately displays a static list of items when submitted to a presenter.</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>Extension functions</h3></th>
</tr>
</thead>
<tbody class="list">
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).filterAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">filterAsync</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;predicate:&nbsp;<a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a>&lt;T,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a><br>)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing only elements matching the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).filterAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">predicate</a></code>.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).flatMapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">flatMapAsync</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;transform:&nbsp;<a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a>&lt;T,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html">Iterable</a>&lt;R&gt;&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a><br>)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> of all elements returned from applying the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).flatMapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">transform</a></code> to each element, as it is loaded.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;R,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertSeparatorsAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">insertSeparatorsAsync</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;generator:&nbsp;<a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a>&lt;<a href="/reference/kotlin/androidx/paging/AdjacentItems.html">AdjacentItems</a>&lt;T&gt;,&nbsp;R?&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a><br>)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with an optional separator generated by <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertSeparatorsAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">generator</a></code>, given the elements before and after (or null, in boundary conditions).</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).mapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">mapAsync</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;transform:&nbsp;<a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a>&lt;T,&nbsp;R&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a><br>)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing the result of applying the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).mapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">transform</a></code> to each element, as it is loaded.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).filter(kotlin.coroutines.SuspendFunction1)">filter</a>(predicate:&nbsp;suspend&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing only elements matching the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).filter(kotlin.coroutines.SuspendFunction1)">predicate</a></code></p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).filter(java.util.concurrent.Executor,kotlin.Function1)">filter</a>(executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a>,&nbsp;predicate:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing only elements matching the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).filter(java.util.concurrent.Executor,kotlin.Function1)">predicate</a></code>.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).flatMap(kotlin.coroutines.SuspendFunction1)">flatMap</a>(transform:&nbsp;suspend&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html">Iterable</a>&lt;R&gt;)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> of all elements returned from applying the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).flatMap(kotlin.coroutines.SuspendFunction1)">transform</a></code> to each element, as it is loaded.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).flatMap(java.util.concurrent.Executor,kotlin.Function1)">flatMap</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;transform:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html">Iterable</a>&lt;R&gt;<br>)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> of all elements returned from applying the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).flatMap(java.util.concurrent.Executor,kotlin.Function1)">transform</a></code> to each element, as it is loaded.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertFooterItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">insertFooterItem</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;terminalSeparatorType:&nbsp;<a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;item:&nbsp;T<br>)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with the passed footer <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertFooterItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">item</a></code> added to the end of the list.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertHeaderItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">insertHeaderItem</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;terminalSeparatorType:&nbsp;<a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;item:&nbsp;T<br>)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with the passed header <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertHeaderItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">item</a></code> added to the start of the list.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;R,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType,kotlin.coroutines.SuspendFunction2)">insertSeparators</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;terminalSeparatorType:&nbsp;<a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;generator:&nbsp;suspend&nbsp;(T?, T?) <span style="white-space: nowrap;">-&gt;</span> R?<br>)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with an optional separator generated by <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType,kotlin.coroutines.SuspendFunction2)">generator</a></code>, given the elements before and after (or null, in boundary conditions).</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;T&nbsp;:&nbsp;R&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType,java.util.concurrent.Executor,kotlin.Function2)">insertSeparators</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;terminalSeparatorType:&nbsp;<a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;generator:&nbsp;(T?, T?) <span style="white-space: nowrap;">-&gt;</span> R?<br>)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with an optional separator generated by <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType,java.util.concurrent.Executor,kotlin.Function2)">generator</a></code>, given the elements before and after (or null, in boundary conditions).</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).map(kotlin.coroutines.SuspendFunction1)">map</a>(transform:&nbsp;suspend&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> R)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing the result of applying the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).map(kotlin.coroutines.SuspendFunction1)">transform</a></code> to each element, as it is loaded.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).map(java.util.concurrent.Executor,kotlin.Function1)">map</a>(executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a>,&nbsp;transform:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> R)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing the result of applying the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).map(java.util.concurrent.Executor,kotlin.Function1)">transform</a></code> to each element, as it is loaded.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).filterAsync(kotlin.Function1)">filterAsync</a>(predicate:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/Single.html">Single</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>&gt;)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing only elements matching the given <code><a href="/reference/kotlin/androidx/paging/rxjava2/package-summary.html#(androidx.paging.PagingData).filterAsync(kotlin.Function1)">predicate</a></code>.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).filterAsync(kotlin.Function1)">filterAsync</a>(predicate:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/rxjava3/core/Single.html">Single</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>&gt;)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing only elements matching the given <code><a href="/reference/kotlin/androidx/paging/rxjava3/package-summary.html#(androidx.paging.PagingData).filterAsync(kotlin.Function1)">predicate</a></code>.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).flatMapAsync(kotlin.Function1)">flatMapAsync</a>(transform:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/Single.html">Single</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html">Iterable</a>&lt;R&gt;&gt;)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> of all elements returned from applying the given <code><a href="/reference/kotlin/androidx/paging/rxjava2/package-summary.html#(androidx.paging.PagingData).flatMapAsync(kotlin.Function1)">transform</a></code> to each element, as it is loaded.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).flatMapAsync(kotlin.Function1)">flatMapAsync</a>(transform:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/rxjava3/core/Single.html">Single</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html">Iterable</a>&lt;R&gt;&gt;)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> of all elements returned from applying the given <code><a href="/reference/kotlin/androidx/paging/rxjava3/package-summary.html#(androidx.paging.PagingData).flatMapAsync(kotlin.Function1)">transform</a></code> to each element, as it is loaded.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;R,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertSeparatorsAsync(kotlin.Function2)">insertSeparatorsAsync</a>(generator:&nbsp;(T?, T?) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/Maybe.html">Maybe</a>&lt;R&gt;)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with an optional separator generated by <code><a href="/reference/kotlin/androidx/paging/rxjava2/package-summary.html#(androidx.paging.PagingData).insertSeparatorsAsync(kotlin.Function2)">generator</a></code>, given the elements before and after (or null, in boundary conditions).</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;R,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertSeparatorsAsync(kotlin.Function2)">insertSeparatorsAsync</a>(generator:&nbsp;(T?, T?) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/rxjava3/core/Maybe.html">Maybe</a>&lt;R&gt;)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with an optional separator generated by <code><a href="/reference/kotlin/androidx/paging/rxjava3/package-summary.html#(androidx.paging.PagingData).insertSeparatorsAsync(kotlin.Function2)">generator</a></code>, given the elements before and after (or null, in boundary conditions).</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).mapAsync(kotlin.Function1)">mapAsync</a>(transform:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/Single.html">Single</a>&lt;R&gt;)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing the result of applying the given <code><a href="/reference/kotlin/androidx/paging/rxjava2/package-summary.html#(androidx.paging.PagingData).mapAsync(kotlin.Function1)">transform</a></code> to each element, as it is loaded.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</code></td>
<td>
<div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).mapAsync(kotlin.Function1)">mapAsync</a>(transform:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/rxjava3/core/Single.html">Single</a>&lt;R&gt;)</code></div>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing the result of applying the given <code><a href="/reference/kotlin/androidx/paging/rxjava3/package-summary.html#(androidx.paging.PagingData).mapAsync(kotlin.Function1)">transform</a></code> to each element, as it is loaded.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="list">
<h2>Public companion functions</h2>
<div class="api-item"><a name="empty--"></a><a name="empty"></a>
<h3 class="api-name" id="empty()">empty</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.Companion.html#empty()">empty</a>():&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</pre>
<p>Create a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> that immediately displays an empty list of items without dispatching any load state updates when submitted to a presenter. E.g., androidx.paging.AsyncPagingDataAdapter.</p>
</div>
<div class="api-item"><a name="empty(androidx.paging.LoadStates, androidx.paging.LoadStates)"></a><a name="empty-androidx.paging.LoadStates-androidx.paging.LoadStates-"></a><a name="empty"></a>
<h3 class="api-name" id="empty(androidx.paging.LoadStates,androidx.paging.LoadStates)">empty</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.Companion.html#empty(androidx.paging.LoadStates,androidx.paging.LoadStates)">empty</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;sourceLoadStates:&nbsp;<a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;mediatorLoadStates:&nbsp;<a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a>? = null<br>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</pre>
<p>Create a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> that immediately displays an empty list of items when submitted to a presenter. E.g., androidx.paging.AsyncPagingDataAdapter.</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>sourceLoadStates:&nbsp;<a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a></code></td>
<td>
<p><code><a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a></code> of <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> to pass forward to a presenter. E.g., androidx.paging.AsyncPagingDataAdapter.</p>
</td>
</tr>
<tr>
<td><code>mediatorLoadStates:&nbsp;<a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a>? = null</code></td>
<td>
<p><code><a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a></code> of <code><a href="/reference/kotlin/androidx/paging/RemoteMediator.html">RemoteMediator</a></code> to pass forward to a presenter. E.g., androidx.paging.AsyncPagingDataAdapter.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="from-kotlin.collections.List-"></a><a name="from"></a>
<h3 class="api-name" id="from(kotlin.collections.List)">from</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.Companion.html#from(kotlin.collections.List)">from</a>(data:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;T&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</pre>
<p>Create a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> that immediately displays a static list of items without dispatching any load state updates when submitted to a presenter. E.g., androidx.paging.AsyncPagingDataAdapter.</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>data:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;T&gt;</code></td>
<td>
<p>Static list of <code><a href="/reference/kotlin/androidx/paging/PagingData.Companion.html#from(kotlin.collections.List)">T</a></code> to display.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="from(kotlin.collections.List, androidx.paging.LoadStates, androidx.paging.LoadStates)"></a><a name="from-kotlin.collections.List-androidx.paging.LoadStates-androidx.paging.LoadStates-"></a><a name="from"></a>
<h3 class="api-name" id="from(kotlin.collections.List,androidx.paging.LoadStates,androidx.paging.LoadStates)">from</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.Companion.html#from(kotlin.collections.List,androidx.paging.LoadStates,androidx.paging.LoadStates)">from</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;data:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;T&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;sourceLoadStates:&nbsp;<a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;mediatorLoadStates:&nbsp;<a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a>? = null<br>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</pre>
<p>Create a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> that immediately displays a static list of items when submitted to a presenter. E.g., androidx.paging.AsyncPagingDataAdapter.</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>data:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a>&lt;T&gt;</code></td>
<td>
<p>Static list of <code><a href="/reference/kotlin/androidx/paging/PagingData.Companion.html#from(kotlin.collections.List,androidx.paging.LoadStates,androidx.paging.LoadStates)">T</a></code> to display.</p>
</td>
</tr>
<tr>
<td><code>sourceLoadStates:&nbsp;<a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a></code></td>
<td>
<p><code><a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a></code> of <code><a href="/reference/kotlin/androidx/paging/PagingSource.html">PagingSource</a></code> to pass forward to a presenter. E.g., androidx.paging.AsyncPagingDataAdapter.</p>
</td>
</tr>
<tr>
<td><code>mediatorLoadStates:&nbsp;<a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a>? = null</code></td>
<td>
<p><code><a href="/reference/kotlin/androidx/paging/LoadStates.html">LoadStates</a></code> of <code><a href="/reference/kotlin/androidx/paging/RemoteMediator.html">RemoteMediator</a></code> to pass forward to a presenter. E.g., androidx.paging.AsyncPagingDataAdapter.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="list">
<h2>Extension functions</h2>
<div class="api-item"><a name="(androidx.paging.PagingData).filterAsync(com.google.common.util.concurrent.AsyncFunction, java.util.concurrent.Executor)"></a><a name="-androidx.paging.PagingData-.filterAsync-com.google.common.util.concurrent.AsyncFunction-java.util.concurrent.Executor-"></a><a name="filterasync"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).filterAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">filterAsync</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).filterAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">filterAsync</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;predicate:&nbsp;<a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a>&lt;T,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a><br>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing only elements matching the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).filterAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">predicate</a></code>.</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>predicate:&nbsp;<a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a>&lt;T,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>&gt;</code></td>
<td>
<p><code><a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a></code> returning <code>false</code> for unmatched items which should be filtered.</p>
</td>
</tr>
<tr>
<td><code>executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a></code></td>
<td>
<p><code><a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a></code> to run the <code><a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a></code> in.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="(androidx.paging.PagingData).flatMapAsync(com.google.common.util.concurrent.AsyncFunction, java.util.concurrent.Executor)"></a><a name="-androidx.paging.PagingData-.flatMapAsync-com.google.common.util.concurrent.AsyncFunction-java.util.concurrent.Executor-"></a><a name="flatmapasync"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).flatMapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">flatMapAsync</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).flatMapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">flatMapAsync</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;transform:&nbsp;<a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a>&lt;T,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html">Iterable</a>&lt;R&gt;&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a><br>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> of all elements returned from applying the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).flatMapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">transform</a></code> to each element, as it is loaded.</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>transform:&nbsp;<a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a>&lt;T,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html">Iterable</a>&lt;R&gt;&gt;</code></td>
<td>
<p><code><a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a></code> to transform an item of type <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).flatMapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">T</a></code> a list of items of type <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).flatMapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">R</a></code>.</p>
</td>
</tr>
<tr>
<td><code>executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a></code></td>
<td>
<p><code><a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a></code> to run the <code><a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a></code> in.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="(androidx.paging.PagingData).insertSeparatorsAsync(com.google.common.util.concurrent.AsyncFunction, java.util.concurrent.Executor)"></a><a name="-androidx.paging.PagingData-.insertSeparatorsAsync-com.google.common.util.concurrent.AsyncFunction-java.util.concurrent.Executor-"></a><a name="insertseparatorsasync"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).insertSeparatorsAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">insertSeparatorsAsync</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;R,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertSeparatorsAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">insertSeparatorsAsync</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;generator:&nbsp;<a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a>&lt;<a href="/reference/kotlin/androidx/paging/AdjacentItems.html">AdjacentItems</a>&lt;T&gt;,&nbsp;R?&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a><br>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with an optional separator generated by <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertSeparatorsAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">generator</a></code>, given the elements before and after (or null, in boundary conditions).</p>
<p>Note that this transform is applied asynchronously, as pages are loaded. Potential separators between pages are only computed once both pages are loaded.</p>
<pre class="prettyprint">
import androidx.paging.insertSeparatorsAsync
import androidx.paging.rxjava2.insertSeparatorsAsync
/*
* Create letter separators in an alphabetically sorted list.
*
* For example, if the input is:
* &quot;apple&quot;, &quot;apricot&quot;, &quot;banana&quot;, &quot;carrot&quot;
*
* The operator would output:
* &quot;A&quot;, &quot;apple&quot;, &quot;apricot&quot;, &quot;B&quot;, &quot;banana&quot;, &quot;C&quot;, &quot;carrot&quot;
*/
pagingDataStream.map { pagingData -&gt;
// map outer stream, so we can perform transformations on each paging generation
pagingData.insertSeparatorsAsync(
AsyncFunction&lt;AdjacentItems&lt;String&gt;, String?&gt; {
Futures.submit(
Callable&lt;String?&gt; {
val (before, after) = it!!
if (after != null &amp;&amp; before?.first() != after.first()) {
// separator - after is first item that starts with its first letter
after.first().toUpperCase().toString()
} else {
// no separator - either end of list, or first letters of before/after are the same
null
}
},
executor
)
},
executor
)
}</pre>
<pre class="prettyprint">
import androidx.paging.insertSeparatorsAsync
import androidx.paging.map
import androidx.paging.rxjava2.insertSeparatorsAsync
open class UiModel
data class ItemUiModel(val item: Item) : UiModel()
data class SeparatorUiModel(val char: Char) : UiModel()
/*
* Create letter separators in an alphabetically sorted list of Items, with UiModel objects.
*
* For example, if the input is (each an `Item`):
* &quot;apple&quot;, &quot;apricot&quot;, &quot;banana&quot;, &quot;carrot&quot;
*
* The operator would output a list of UiModels corresponding to:
* &quot;A&quot;, &quot;apple&quot;, &quot;apricot&quot;, &quot;B&quot;, &quot;banana&quot;, &quot;C&quot;, &quot;carrot&quot;
*/
pagingDataStream.map { pagingData -&gt;
// map outer stream, so we can perform transformations on each paging generation
pagingData
.map { item -&gt;
ItemUiModel(item) // convert items in stream to ItemUiModel
}
.insertSeparatorsAsync(
AsyncFunction&lt;AdjacentItems&lt;ItemUiModel&gt;, UiModel?&gt; {
Futures.submit(
Callable&lt;UiModel&gt; {
val (before, after) = it!!
if (after != null &amp;&amp;
before?.item?.label?.first() != after.item.label.first()
) {
// separator - after is first item that starts with its first letter
SeparatorUiModel(after.item.label.first().toUpperCase())
} else {
// no separator - either end of list, or first letters of before/after are the same
null
}
},
executor
)
},
executor
)
}</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>generator:&nbsp;<a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a>&lt;<a href="/reference/kotlin/androidx/paging/AdjacentItems.html">AdjacentItems</a>&lt;T&gt;,&nbsp;R?&gt;</code></td>
<td>
<p><code><a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a></code> used to generate separator between two <code><a href="/reference/kotlin/androidx/paging/AdjacentItems.html">AdjacentItems</a></code> or the header or footer if either <code><a href="/reference/kotlin/androidx/paging/AdjacentItems.html#before()">AdjacentItems.before</a></code> or <code><a href="/reference/kotlin/androidx/paging/AdjacentItems.html#after()">AdjacentItems.after</a></code> is <code>null</code>.</p>
</td>
</tr>
<tr>
<td><code>executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a></code></td>
<td>
<p><code><a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a></code> to run the <code><a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a></code> in.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="(androidx.paging.PagingData).mapAsync(com.google.common.util.concurrent.AsyncFunction, java.util.concurrent.Executor)"></a><a name="-androidx.paging.PagingData-.mapAsync-com.google.common.util.concurrent.AsyncFunction-java.util.concurrent.Executor-"></a><a name="mapasync"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).mapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">mapAsync</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).mapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">mapAsync</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;transform:&nbsp;<a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a>&lt;T,&nbsp;R&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a><br>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing the result of applying the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).mapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">transform</a></code> to each element, as it is loaded.</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>transform:&nbsp;<a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a>&lt;T,&nbsp;R&gt;</code></td>
<td>
<p><code><a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a></code> to transform an item of type <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).mapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">T</a></code> to <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).mapAsync(com.google.common.util.concurrent.AsyncFunction,java.util.concurrent.Executor)">R</a></code>.</p>
</td>
</tr>
<tr>
<td><code>executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a></code></td>
<td>
<p><code><a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a></code> to run the <code><a href="https://guava.dev/releases/18.0/api/docs/package-list/com/google/common/util/concurrent/AsyncFunction.html">AsyncFunction</a></code> in.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="-androidx.paging.PagingData-.filter-kotlin.coroutines.SuspendFunction1-"></a><a name="filter"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).filter(kotlin.coroutines.SuspendFunction1)">filter</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).filter(kotlin.coroutines.SuspendFunction1)">filter</a>(predicate:&nbsp;suspend&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing only elements matching the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).filter(kotlin.coroutines.SuspendFunction1)">predicate</a></code></p>
</div>
<div class="api-item"><a name="(androidx.paging.PagingData).filter(java.util.concurrent.Executor, kotlin.Function1)"></a><a name="-androidx.paging.PagingData-.filter-java.util.concurrent.Executor-kotlin.Function1-"></a><a name="filter"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).filter(java.util.concurrent.Executor,kotlin.Function1)">filter</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).filter(java.util.concurrent.Executor,kotlin.Function1)">filter</a>(executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a>,&nbsp;predicate:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing only elements matching the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).filter(java.util.concurrent.Executor,kotlin.Function1)">predicate</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/package-summary.html#(androidx.paging.PagingData).filter(kotlin.coroutines.SuspendFunction1)">filter</a></code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="-androidx.paging.PagingData-.flatMap-kotlin.coroutines.SuspendFunction1-"></a><a name="flatmap"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).flatMap(kotlin.coroutines.SuspendFunction1)">flatMap</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).flatMap(kotlin.coroutines.SuspendFunction1)">flatMap</a>(transform:&nbsp;suspend&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html">Iterable</a>&lt;R&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> of all elements returned from applying the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).flatMap(kotlin.coroutines.SuspendFunction1)">transform</a></code> to each element, as it is loaded.</p>
</div>
<div class="api-item"><a name="(androidx.paging.PagingData).flatMap(java.util.concurrent.Executor, kotlin.Function1)"></a><a name="-androidx.paging.PagingData-.flatMap-java.util.concurrent.Executor-kotlin.Function1-"></a><a name="flatmap"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).flatMap(java.util.concurrent.Executor,kotlin.Function1)">flatMap</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).flatMap(java.util.concurrent.Executor,kotlin.Function1)">flatMap</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;transform:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html">Iterable</a>&lt;R&gt;<br>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> of all elements returned from applying the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).flatMap(java.util.concurrent.Executor,kotlin.Function1)">transform</a></code> to each element, as it is loaded.</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/package-summary.html#(androidx.paging.PagingData).flatMap(kotlin.coroutines.SuspendFunction1)">flatMap</a></code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="(androidx.paging.PagingData).insertFooterItem(androidx.paging.TerminalSeparatorType, kotlin.Any)"></a><a name="-androidx.paging.PagingData-.insertFooterItem-androidx.paging.TerminalSeparatorType-kotlin.Any-"></a><a name="insertfooteritem"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).insertFooterItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">insertFooterItem</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertFooterItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">insertFooterItem</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;terminalSeparatorType:&nbsp;<a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a> = FULLY_COMPLETE,<br>&nbsp;&nbsp;&nbsp;&nbsp;item:&nbsp;T<br>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with the passed footer <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertFooterItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">item</a></code> added to the end of the list.</p>
<p>The footer <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertFooterItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">item</a></code> is added to a loaded page which marks the end of the data stream in the <code><a href="/reference/kotlin/androidx/paging/LoadType.html#APPEND">LoadType.APPEND</a></code> direction, either by returning null in <code><a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page.html#nextKey()">PagingSource.LoadResult.Page.nextKey</a></code>. It will be removed if the last page in the list is dropped, which can happen in the case of loaded pages exceeding <code><a href="/reference/kotlin/androidx/paging/PagedList.Config.html#maxSize()">PagedList.Config.maxSize</a></code>.</p>
<p>Note: This operation is not idempotent, calling it multiple times will continually add more footers to the end of the list, which can be useful if multiple footer items are required.</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>terminalSeparatorType:&nbsp;<a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a> = FULLY_COMPLETE</code></td>
<td>
<p><code><a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a></code> used to configure when the header and footer are added.</p>
</td>
</tr>
<tr>
<td><code>item:&nbsp;T</code></td>
<td>
<p>The footer to add to the end of the list once it is fully loaded in the <code><a href="/reference/kotlin/androidx/paging/LoadType.html#APPEND">LoadType.APPEND</a></code> direction.</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/package-summary.html#(androidx.paging.PagingData).insertHeaderItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">insertHeaderItem</a></code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="(androidx.paging.PagingData).insertHeaderItem(androidx.paging.TerminalSeparatorType, kotlin.Any)"></a><a name="-androidx.paging.PagingData-.insertHeaderItem-androidx.paging.TerminalSeparatorType-kotlin.Any-"></a><a name="insertheaderitem"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).insertHeaderItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">insertHeaderItem</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertHeaderItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">insertHeaderItem</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;terminalSeparatorType:&nbsp;<a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a> = FULLY_COMPLETE,<br>&nbsp;&nbsp;&nbsp;&nbsp;item:&nbsp;T<br>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with the passed header <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertHeaderItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">item</a></code> added to the start of the list.</p>
<p>The header <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertHeaderItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">item</a></code> is added to a loaded page which marks the end of the data stream in the <code><a href="/reference/kotlin/androidx/paging/LoadType.html#PREPEND">LoadType.PREPEND</a></code> direction by returning null in <code><a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page.html#prevKey()">PagingSource.LoadResult.Page.prevKey</a></code>. It will be removed if the first page in the list is dropped, which can happen in the case of loaded pages exceeding <code><a href="/reference/kotlin/androidx/paging/PagedList.Config.html#maxSize()">PagedList.Config.maxSize</a></code>.</p>
<p>Note: This operation is not idempotent, calling it multiple times will continually add more headers to the start of the list, which can be useful if multiple header items are required.</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>terminalSeparatorType:&nbsp;<a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a> = FULLY_COMPLETE</code></td>
<td>
<p><code><a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a></code> used to configure when the header and footer are added.</p>
</td>
</tr>
<tr>
<td><code>item:&nbsp;T</code></td>
<td>
<p>The header to add to the front of the list once it is fully loaded in the <code><a href="/reference/kotlin/androidx/paging/LoadType.html#PREPEND">LoadType.PREPEND</a></code> direction.</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/package-summary.html#(androidx.paging.PagingData).insertFooterItem(androidx.paging.TerminalSeparatorType,kotlin.Any)">insertFooterItem</a></code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType, kotlin.coroutines.SuspendFunction2)"></a><a name="-androidx.paging.PagingData-.insertSeparators-androidx.paging.TerminalSeparatorType-kotlin.coroutines.SuspendFunction2-"></a><a name="insertseparators"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType,kotlin.coroutines.SuspendFunction2)">insertSeparators</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;R,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType,kotlin.coroutines.SuspendFunction2)">insertSeparators</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;terminalSeparatorType:&nbsp;<a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a> = FULLY_COMPLETE,<br>&nbsp;&nbsp;&nbsp;&nbsp;generator:&nbsp;suspend&nbsp;(T?, T?) <span style="white-space: nowrap;">-&gt;</span> R?<br>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with an optional separator generated by <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType,kotlin.coroutines.SuspendFunction2)">generator</a></code>, given the elements before and after (or null, in boundary conditions).</p>
<p>Note that this transform is applied asynchronously, as pages are loaded. Potential separators between pages are only computed once both pages are loaded.</p>
<pre class="prettyprint">
import androidx.paging.insertSeparators
/*
* Create letter separators in an alphabetically sorted list.
*
* For example, if the input is:
* &quot;apple&quot;, &quot;apricot&quot;, &quot;banana&quot;, &quot;carrot&quot;
*
* The operator would output:
* &quot;A&quot;, &quot;apple&quot;, &quot;apricot&quot;, &quot;B&quot;, &quot;banana&quot;, &quot;C&quot;, &quot;carrot&quot;
*/
pagingDataStream.map { pagingData -&gt;
// map outer stream, so we can perform transformations on each paging generation
pagingData.insertSeparators { before: String?, after: String? -&gt;
if (after != null &amp;&amp; before?.first() != after.first()) {
// separator - after is first item that starts with its first letter
after.first().toUpperCase().toString()
} else {
// no separator - either end of list, or first letters of before/after are the same
null
}
}
}</pre>
<pre class="prettyprint">
import androidx.paging.insertSeparators
import androidx.paging.map
open class UiModel
data class ItemUiModel(val item: Item) : UiModel()
data class SeparatorUiModel(val char: Char) : UiModel()
/*
* Create letter separators in an alphabetically sorted list of Items, with UiModel objects.
*
* For example, if the input is (each an `Item`):
* &quot;apple&quot;, &quot;apricot&quot;, &quot;banana&quot;, &quot;carrot&quot;
*
* The operator would output a list of UiModels corresponding to:
* &quot;A&quot;, &quot;apple&quot;, &quot;apricot&quot;, &quot;B&quot;, &quot;banana&quot;, &quot;C&quot;, &quot;carrot&quot;
*/
pagingDataStream.map { pagingData -&gt;
// map outer stream, so we can perform transformations on each paging generation
pagingData
.map { item -&gt;
ItemUiModel(item) // convert items in stream to ItemUiModel
}
.insertSeparators&lt;ItemUiModel, UiModel&gt; { before: ItemUiModel?, after: ItemUiModel? -&gt;
if (after != null &amp;&amp; before?.item?.label?.first() != after.item.label.first()) {
// separator - after is first item that starts with its first letter
SeparatorUiModel(after.item.label.first().toUpperCase())
} else {
// no separator - either end of list, or first letters of before/after are the same
null
}
}
}</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>terminalSeparatorType:&nbsp;<a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a> = FULLY_COMPLETE</code></td>
<td>
<p><code><a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a></code> used to configure when the header and footer are added.</p>
</td>
</tr>
<tr>
<td><code>generator:&nbsp;suspend&nbsp;(T?, T?) <span style="white-space: nowrap;">-&gt;</span> R?</code></td>
<td>
<p>Generator function used to construct a separator item given the item before and the item after. For terminal separators (header and footer), the arguments passed to the generator, <code>before</code> and <code>after</code>, will be <code>null</code> respectively. In cases where the fully paginated list is empty, a single separator will be added where both <code>before</code> and <code>after</code> items are <code>null</code>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType, java.util.concurrent.Executor, kotlin.Function2)"></a><a name="-androidx.paging.PagingData-.insertSeparators-androidx.paging.TerminalSeparatorType-java.util.concurrent.Executor-kotlin.Function2-"></a><a name="insertseparators"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType,java.util.concurrent.Executor,kotlin.Function2)">insertSeparators</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;T&nbsp;:&nbsp;R&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType,java.util.concurrent.Executor,kotlin.Function2)">insertSeparators</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;terminalSeparatorType:&nbsp;<a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a> = FULLY_COMPLETE,<br>&nbsp;&nbsp;&nbsp;&nbsp;executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;generator:&nbsp;(T?, T?) <span style="white-space: nowrap;">-&gt;</span> R?<br>):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with an optional separator generated by <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType,java.util.concurrent.Executor,kotlin.Function2)">generator</a></code>, given the elements before and after (or null, in boundary conditions).</p>
<p>Note that this transform is applied asynchronously, as pages are loaded. Potential separators between pages are only computed once both pages are loaded.</p>
<p><b>Kotlin callers should instead use the suspending extension function variant of insertSeparators</b></p>
<pre class="prettyprint">/*<br> * Create letter separators in an alphabetically sorted list.<br> *<br> * For example, if the input is:<br> * &quot;apple&quot;, &quot;apricot&quot;, &quot;banana&quot;, &quot;carrot&quot;<br> *<br> * The operator would output:<br> * &quot;A&quot;, &quot;apple&quot;, &quot;apricot&quot;, &quot;B&quot;, &quot;banana&quot;, &quot;C&quot;, &quot;carrot&quot;<br> */<br>pagingDataStream.map(pagingData -&gt;<br> // map outer stream, so we can perform transformations on each paging generation<br> PagingDataTransforms.insertSeparators(pagingData, bgExecutor,<br> (@Nullable String before, @Nullable String after) -&gt; {<br> if (after != null &amp;&amp; (before == null<br> || before.charAt(0) != after.charAt(0))) {<br> // separator - after is first item that starts with its first<br> // letter<br> return Character.toString(<br> Character.toUpperCase(after.charAt(0)));<br> } else {<br> // no separator - either end of list, or first<br> // letters of items are the same<br> return null;<br> }<br> }));<br><br>/*<br> * Create letter separators in an alphabetically sorted list of Items, with UiModel<br> * objects.<br> *<br> * For example, if the input is (each an `Item`):<br> * &quot;apple&quot;, &quot;apricot&quot;, &quot;banana&quot;, &quot;carrot&quot;<br> *<br> * The operator would output a list of UiModels corresponding to:<br> * &quot;A&quot;, &quot;apple&quot;, &quot;apricot&quot;, &quot;B&quot;, &quot;banana&quot;, &quot;C&quot;, &quot;carrot&quot;<br> */<br>pagingDataStream.map(itemPagingData -&gt; {<br> // map outer stream, so we can perform transformations on each paging generation<br><br> // first convert items in stream to UiModel.Item<br> PagingData&lt;UiModel.ItemModel&gt; itemModelPagingData = PagingDataTransforms.map(<br> itemPagingData, bgExecutor, UiModel.ItemModel::new);<br><br> // Now insert UiModel.Separators, which makes the PagingData of generic type UiModel<br> return PagingDataTransforms.insertSeparators(<br> itemModelPagingData, bgExecutor,<br> (@Nullable UiModel.ItemModel before, @Nullable UiModel.ItemModel after) -&gt; {<br> if (after != null &amp;&amp; (before == null<br> || before.item.label.charAt(0) != after.item.label.charAt(0))) {<br> // separator - after is first item that starts with its first letter<br> return new UiModel.SeparatorModel(<br> Character.toUpperCase(after.item.label.charAt(0)));<br> } else {<br> // no separator - either end of list, or first<br> // letters of items are the same<br> return null;<br> }<br> });<br>});<br><br>public class UiModel {<br> static class ItemModel extends UiModel {<br> public Item item;<br> ItemModel(Item item) {<br> this.item = item;<br> }<br> }<br> static class SeparatorModel extends UiModel {<br> public char character;<br> SeparatorModel(char character) {<br> this.character = character;<br> }<br> }<br>}</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>terminalSeparatorType:&nbsp;<a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a> = FULLY_COMPLETE</code></td>
<td>
<p><code><a href="/reference/kotlin/androidx/paging/TerminalSeparatorType.html">TerminalSeparatorType</a></code> used to configure when the header and footer are added.</p>
</td>
</tr>
<tr>
<td><code>executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a></code></td>
<td>
<p><code><a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a></code> to run the <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).insertSeparators(androidx.paging.TerminalSeparatorType,java.util.concurrent.Executor,kotlin.Function2)">generator</a></code> function in.</p>
</td>
</tr>
<tr>
<td><code>generator:&nbsp;(T?, T?) <span style="white-space: nowrap;">-&gt;</span> R?</code></td>
<td>
<p>Generator function used to construct a separator item given the item before and the item after. For terminal separators (header and footer), the arguments passed to the generator, <code>before</code> and <code>after</code>, will be <code>null</code> respectively. In cases where the fully paginated list is empty, a single separator will be added where both <code>before</code> and <code>after</code> items are <code>null</code>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="-androidx.paging.PagingData-.map-kotlin.coroutines.SuspendFunction1-"></a><a name="map"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).map(kotlin.coroutines.SuspendFunction1)">map</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).map(kotlin.coroutines.SuspendFunction1)">map</a>(transform:&nbsp;suspend&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> R):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing the result of applying the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).map(kotlin.coroutines.SuspendFunction1)">transform</a></code> to each element, as it is loaded.</p>
</div>
<div class="api-item"><a name="(androidx.paging.PagingData).map(java.util.concurrent.Executor, kotlin.Function1)"></a><a name="-androidx.paging.PagingData-.map-java.util.concurrent.Executor-kotlin.Function1-"></a><a name="map"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).map(java.util.concurrent.Executor,kotlin.Function1)">map</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).map(java.util.concurrent.Executor,kotlin.Function1)">map</a>(executor:&nbsp;<a href="https://developer.android.com/reference/java/util/concurrent/Executor.html">Executor</a>,&nbsp;transform:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> R):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing the result of applying the given <code><a href="/reference/kotlin/androidx/paging/package-summary.html#(androidx.paging.PagingData).map(java.util.concurrent.Executor,kotlin.Function1)">transform</a></code> to each element, as it is loaded.</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/package-summary.html#(androidx.paging.PagingData).map(kotlin.coroutines.SuspendFunction1)">map</a></code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="-androidx.paging.PagingData-.filterAsync-kotlin.Function1-"></a><a name="filterasync"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).filterAsync(kotlin.Function1)">filterAsync</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).filterAsync(kotlin.Function1)">filterAsync</a>(predicate:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/Single.html">Single</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing only elements matching the given <code><a href="/reference/kotlin/androidx/paging/rxjava2/package-summary.html#(androidx.paging.PagingData).filterAsync(kotlin.Function1)">predicate</a></code>.</p>
</div>
<div class="api-item"><a name="-androidx.paging.PagingData-.filterAsync-kotlin.Function1-"></a><a name="filterasync"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).filterAsync(kotlin.Function1)">filterAsync</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).filterAsync(kotlin.Function1)">filterAsync</a>(predicate:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/rxjava3/core/Single.html">Single</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing only elements matching the given <code><a href="/reference/kotlin/androidx/paging/rxjava3/package-summary.html#(androidx.paging.PagingData).filterAsync(kotlin.Function1)">predicate</a></code>.</p>
</div>
<div class="api-item"><a name="-androidx.paging.PagingData-.flatMapAsync-kotlin.Function1-"></a><a name="flatmapasync"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).flatMapAsync(kotlin.Function1)">flatMapAsync</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).flatMapAsync(kotlin.Function1)">flatMapAsync</a>(transform:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/Single.html">Single</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html">Iterable</a>&lt;R&gt;&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> of all elements returned from applying the given <code><a href="/reference/kotlin/androidx/paging/rxjava2/package-summary.html#(androidx.paging.PagingData).flatMapAsync(kotlin.Function1)">transform</a></code> to each element, as it is loaded.</p>
</div>
<div class="api-item"><a name="-androidx.paging.PagingData-.flatMapAsync-kotlin.Function1-"></a><a name="flatmapasync"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).flatMapAsync(kotlin.Function1)">flatMapAsync</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).flatMapAsync(kotlin.Function1)">flatMapAsync</a>(transform:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/rxjava3/core/Single.html">Single</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html">Iterable</a>&lt;R&gt;&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> of all elements returned from applying the given <code><a href="/reference/kotlin/androidx/paging/rxjava3/package-summary.html#(androidx.paging.PagingData).flatMapAsync(kotlin.Function1)">transform</a></code> to each element, as it is loaded.</p>
</div>
<div class="api-item"><a name="-androidx.paging.PagingData-.insertSeparatorsAsync-kotlin.Function2-"></a><a name="insertseparatorsasync"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).insertSeparatorsAsync(kotlin.Function2)">insertSeparatorsAsync</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;R,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertSeparatorsAsync(kotlin.Function2)">insertSeparatorsAsync</a>(generator:&nbsp;(T?, T?) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/Maybe.html">Maybe</a>&lt;R&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with an optional separator generated by <code><a href="/reference/kotlin/androidx/paging/rxjava2/package-summary.html#(androidx.paging.PagingData).insertSeparatorsAsync(kotlin.Function2)">generator</a></code>, given the elements before and after (or null, in boundary conditions).</p>
<p>Note that this transform is applied asynchronously, as pages are loaded. Potential separators between pages are only computed once both pages are loaded.</p>
<pre class="prettyprint">
import androidx.paging.insertSeparatorsAsync
import androidx.paging.rxjava2.insertSeparatorsAsync
/*
* Create letter separators in an alphabetically sorted list.
*
* For example, if the input is:
* &quot;apple&quot;, &quot;apricot&quot;, &quot;banana&quot;, &quot;carrot&quot;
*
* The operator would output:
* &quot;A&quot;, &quot;apple&quot;, &quot;apricot&quot;, &quot;B&quot;, &quot;banana&quot;, &quot;C&quot;, &quot;carrot&quot;
*/
pagingDataStream.map { pagingData -&gt;
// map outer stream, so we can perform transformations on each paging generation
pagingData.insertSeparatorsAsync { before: String?, after: String? -&gt;
Maybe.fromCallable&lt;String&gt; {
if (after != null &amp;&amp; before?.first() != after.first()) {
// separator - after is first item that starts with its first letter
after.first().toUpperCase().toString()
} else {
// no separator - either end of list, or first letters of before/after are the same
null
}
}.subscribeOn(Schedulers.computation())
}
}</pre>
<pre class="prettyprint">
import androidx.paging.insertSeparatorsAsync
import androidx.paging.map
import androidx.paging.rxjava2.insertSeparatorsAsync
open class UiModel
data class ItemUiModel(val item: Item) : UiModel()
data class SeparatorUiModel(val char: Char) : UiModel()
/*
* Create letter separators in an alphabetically sorted list of Items, with UiModel objects.
*
* For example, if the input is (each an `Item`):
* &quot;apple&quot;, &quot;apricot&quot;, &quot;banana&quot;, &quot;carrot&quot;
*
* The operator would output a list of UiModels corresponding to:
* &quot;A&quot;, &quot;apple&quot;, &quot;apricot&quot;, &quot;B&quot;, &quot;banana&quot;, &quot;C&quot;, &quot;carrot&quot;
*/
pagingDataStream.map { pagingData -&gt;
// map outer stream, so we can perform transformations on each paging generation
pagingData
.map { item -&gt;
ItemUiModel(item) // convert items in stream to ItemUiModel
}
.insertSeparatorsAsync { before: ItemUiModel?, after: ItemUiModel? -&gt;
Maybe.fromCallable&lt;UiModel&gt; {
if (after != null &amp;&amp; before?.item?.label?.first() != after.item.label.first()) {
// separator - after is first item that starts with its first letter
SeparatorUiModel(after.item.label.first().toUpperCase())
} else {
// no separator - either end of list, or first letters of before/after are the same
null
}
}.subscribeOn(Schedulers.computation())
}
}</pre>
</div>
<div class="api-item"><a name="-androidx.paging.PagingData-.insertSeparatorsAsync-kotlin.Function2-"></a><a name="insertseparatorsasync"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).insertSeparatorsAsync(kotlin.Function2)">insertSeparatorsAsync</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;R,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).insertSeparatorsAsync(kotlin.Function2)">insertSeparatorsAsync</a>(generator:&nbsp;(T?, T?) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/rxjava3/core/Maybe.html">Maybe</a>&lt;R&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing each original element, with an optional separator generated by <code><a href="/reference/kotlin/androidx/paging/rxjava3/package-summary.html#(androidx.paging.PagingData).insertSeparatorsAsync(kotlin.Function2)">generator</a></code>, given the elements before and after (or null, in boundary conditions).</p>
<p>Note that this transform is applied asynchronously, as pages are loaded. Potential separators between pages are only computed once both pages are loaded.</p>
<pre class="prettyprint">
import androidx.paging.insertSeparatorsAsync
import androidx.paging.rxjava2.insertSeparatorsAsync
/*
* Create letter separators in an alphabetically sorted list.
*
* For example, if the input is:
* &quot;apple&quot;, &quot;apricot&quot;, &quot;banana&quot;, &quot;carrot&quot;
*
* The operator would output:
* &quot;A&quot;, &quot;apple&quot;, &quot;apricot&quot;, &quot;B&quot;, &quot;banana&quot;, &quot;C&quot;, &quot;carrot&quot;
*/
pagingDataStream.map { pagingData -&gt;
// map outer stream, so we can perform transformations on each paging generation
pagingData.insertSeparatorsAsync { before: String?, after: String? -&gt;
Maybe.fromCallable&lt;String&gt; {
if (after != null &amp;&amp; before?.first() != after.first()) {
// separator - after is first item that starts with its first letter
after.first().toUpperCase().toString()
} else {
// no separator - either end of list, or first letters of before/after are the same
null
}
}.subscribeOn(Schedulers.computation())
}
}</pre>
<pre class="prettyprint">
import androidx.paging.insertSeparatorsAsync
import androidx.paging.map
import androidx.paging.rxjava2.insertSeparatorsAsync
open class UiModel
data class ItemUiModel(val item: Item) : UiModel()
data class SeparatorUiModel(val char: Char) : UiModel()
/*
* Create letter separators in an alphabetically sorted list of Items, with UiModel objects.
*
* For example, if the input is (each an `Item`):
* &quot;apple&quot;, &quot;apricot&quot;, &quot;banana&quot;, &quot;carrot&quot;
*
* The operator would output a list of UiModels corresponding to:
* &quot;A&quot;, &quot;apple&quot;, &quot;apricot&quot;, &quot;B&quot;, &quot;banana&quot;, &quot;C&quot;, &quot;carrot&quot;
*/
pagingDataStream.map { pagingData -&gt;
// map outer stream, so we can perform transformations on each paging generation
pagingData
.map { item -&gt;
ItemUiModel(item) // convert items in stream to ItemUiModel
}
.insertSeparatorsAsync { before: ItemUiModel?, after: ItemUiModel? -&gt;
Maybe.fromCallable&lt;UiModel&gt; {
if (after != null &amp;&amp; before?.item?.label?.first() != after.item.label.first()) {
// separator - after is first item that starts with its first letter
SeparatorUiModel(after.item.label.first().toUpperCase())
} else {
// no separator - either end of list, or first letters of before/after are the same
null
}
}.subscribeOn(Schedulers.computation())
}
}</pre>
</div>
<div class="api-item"><a name="-androidx.paging.PagingData-.mapAsync-kotlin.Function1-"></a><a name="mapasync"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).mapAsync(kotlin.Function1)">mapAsync</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).mapAsync(kotlin.Function1)">mapAsync</a>(transform:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/Single.html">Single</a>&lt;R&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing the result of applying the given <code><a href="/reference/kotlin/androidx/paging/rxjava2/package-summary.html#(androidx.paging.PagingData).mapAsync(kotlin.Function1)">transform</a></code> to each element, as it is loaded.</p>
</div>
<div class="api-item"><a name="-androidx.paging.PagingData-.mapAsync-kotlin.Function1-"></a><a name="mapasync"></a>
<h3 class="api-name" id="(androidx.paging.PagingData).mapAsync(kotlin.Function1)">mapAsync</h3>
<pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>,&nbsp;R&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>&gt; <a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;.<a href="/reference/kotlin/androidx/paging/PagingData.html#(androidx.paging.PagingData).mapAsync(kotlin.Function1)">mapAsync</a>(transform:&nbsp;(T) <span style="white-space: nowrap;">-&gt;</span> <a href="/reference/kotlin/io/reactivex/rxjava3/core/Single.html">Single</a>&lt;R&gt;):&nbsp;<a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a>&lt;R&gt;</pre>
<p>Returns a <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> containing the result of applying the given <code><a href="/reference/kotlin/androidx/paging/rxjava3/package-summary.html#(androidx.paging.PagingData).mapAsync(kotlin.Function1)">transform</a></code> to each element, as it is loaded.</p>
</div>
</div>
</body>
</html>