blob: 1d5cea85b6adcc6617c6adec1f8015bb10a34d2e [file] [log] [blame]
<html devsite="true">
<head>
<title>RxRemoteMediator</title>
{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %}
{% include "_shared/_reference-head-tags.html" %}
</head>
<body>
<h1>RxRemoteMediator</h1>
{% setvar page_path %}androidx/paging/rxjava2/RxRemoteMediator.html{% endsetvar %}
{% setvar can_switch %}1{% endsetvar %}
{% include "reference/_java_switcher2.md" %}
<p>
<pre>public abstract class RxRemoteMediator&lt;Key&nbsp;extends&nbsp;<a href="/reference/java/lang/Object.html">Object</a>,&nbsp;Value&nbsp;extends&nbsp;<a href="/reference/java/lang/Object.html">Object</a>&gt; extends <a href="/reference/androidx/paging/RemoteMediator.html">RemoteMediator</a></pre>
</p>
<div class="devsite-table-wrapper">
<table class="jd-inheritance-table">
<tbody>
<tr>
<td colspan="3"><a href="/reference/java/lang/Object.html">Object</a></td>
</tr>
<tr>
<td class="jd-inheritance-space">&nbsp;&nbsp;&nbsp;↳</td>
<td colspan="2"><a href="/reference/androidx/paging/RemoteMediator.html">RemoteMediator</a></td>
</tr>
<tr>
<td>&nbsp;</td>
<td class="jd-inheritance-space">&nbsp;&nbsp;&nbsp;↳</td>
<td colspan="1"><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html">RxRemoteMediator</a></td>
</tr>
</tbody>
</table>
</div>
<hr>
<p>RxJava2 compatibility wrapper around <code><a href="/reference/androidx/paging/RemoteMediator.html">RemoteMediator</a></code>'s suspending APIs.</p>
<h2>Summary</h2>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2"><h3>Public constructors</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div><code>&lt;Key&nbsp;extends&nbsp;<a href="/reference/java/lang/Object.html">Object</a>,&nbsp;Value&nbsp;extends&nbsp;<a href="/reference/java/lang/Object.html">Object</a>&gt; <a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#RxRemoteMediator()">RxRemoteMediator</a>()</code></div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2"><h3>Public methods</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td><code>final <a href="/reference/androidx/paging/RemoteMediator.InitializeAction.html">RemoteMediator.InitializeAction</a></code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#initialize()">initialize</a>()</code></div>
<p>Callback fired during initialization of a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> stream, before initial load.</p>
</td>
</tr>
<tr>
<td><code><a href="/reference/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;<a href="/reference/androidx/paging/RemoteMediator.InitializeAction.html">RemoteMediator.InitializeAction</a>&gt;</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#initializeSingle()">initializeSingle</a>()</code></div>
<p>Callback fired during initialization of a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> stream, before initial load.</p>
</td>
</tr>
<tr>
<td><code>final <a href="/reference/androidx/paging/RemoteMediator.MediatorResult.html">RemoteMediator.MediatorResult</a></code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#load(androidx.paging.LoadType,androidx.paging.PagingState)">load</a>(<a href="/reference/androidx/paging/LoadType.html">LoadType</a>&nbsp;loadType,&nbsp;<a href="/reference/androidx/paging/PagingState.html">PagingState</a>&lt;Key,&nbsp;Value&gt;&nbsp;state)</code></div>
<p>Implement this method to load additional remote data, which will then be stored for the <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> to access.</p>
</td>
</tr>
<tr>
<td><code>abstract <a href="/reference/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;<a href="/reference/androidx/paging/RemoteMediator.MediatorResult.html">RemoteMediator.MediatorResult</a>&gt;</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#loadSingle(androidx.paging.LoadType,androidx.paging.PagingState)">loadSingle</a>(<a href="/reference/androidx/paging/LoadType.html">LoadType</a>&nbsp;loadType,&nbsp;<a href="/reference/androidx/paging/PagingState.html">PagingState</a>&lt;Key,&nbsp;Value&gt;&nbsp;state)</code></div>
<p>Implement this method to load additional remote data, which will then be stored for the <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> to access.</p>
</td>
</tr>
</tbody>
</table>
</div>
<h2>Public constructors</h2>
<div><a name="RxRemoteMediator--"></a>
<h3 class="api-name" id="RxRemoteMediator()">RxRemoteMediator</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;&lt;Key&nbsp;extends&nbsp;<a href="/reference/java/lang/Object.html">Object</a>,&nbsp;Value&nbsp;extends&nbsp;<a href="/reference/java/lang/Object.html">Object</a>&gt; <a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#RxRemoteMediator()">RxRemoteMediator</a>()</pre>
</div>
<h2>Public methods</h2>
<div><a name="initialize--"></a>
<h3 class="api-name" id="initialize()">initialize</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;<a href="/reference/androidx/paging/RemoteMediator.InitializeAction.html">RemoteMediator.InitializeAction</a>&nbsp;<a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#initialize()">initialize</a>()</pre>
<p>Callback fired during initialization of a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> stream, before initial load.</p>
<p>This function runs to completion before any loading is performed.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/androidx/paging/RemoteMediator.InitializeAction.html">RemoteMediator.InitializeAction</a></code></td>
<td width="100%">
<p><code><a href="/reference/androidx/paging/RemoteMediator.InitializeAction.html">InitializeAction</a></code> indicating the action to take after initialization:</p>
<ul>
<li>
<p><code><a href="/reference/androidx/paging/RemoteMediator.InitializeAction.LAUNCH_INITIAL_REFRESH.html">LAUNCH_INITIAL_REFRESH</a></code> to immediately dispatch a <code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#load(androidx.paging.LoadType,androidx.paging.PagingState)">load</a></code> asynchronously with load type <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code>, to update paginated content when the stream is initialized.</p>
</li>
<li>
<p><code><a href="/reference/androidx/paging/RemoteMediator.InitializeAction.SKIP_INITIAL_REFRESH.html">SKIP_INITIAL_REFRESH</a></code> to wait for a refresh request from the UI before dispatching a <code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#load(androidx.paging.LoadType,androidx.paging.PagingState)">load</a></code> with load type <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code>.</p>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="initializeSingle--"></a>
<h3 class="api-name" id="initializeSingle()">initializeSingle</h3>
<pre class="api-signature no-pretty-print">public&nbsp;<a href="/reference/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;<a href="/reference/androidx/paging/RemoteMediator.InitializeAction.html">RemoteMediator.InitializeAction</a>&gt;&nbsp;<a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#initializeSingle()">initializeSingle</a>()</pre>
<p>Callback fired during initialization of a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> stream, before initial load.</p>
<p>This function runs to completion before any loading is performed.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;<a href="/reference/androidx/paging/RemoteMediator.InitializeAction.html">RemoteMediator.InitializeAction</a>&gt;</code></td>
<td width="100%">
<p><code><a href="/reference/androidx/paging/RemoteMediator.InitializeAction.html">InitializeAction</a></code> indicating the action to take after initialization:</p>
<ul>
<li>
<p><code><a href="/reference/androidx/paging/RemoteMediator.InitializeAction.LAUNCH_INITIAL_REFRESH.html">LAUNCH_INITIAL_REFRESH</a></code> to immediately dispatch a <code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#load(androidx.paging.LoadType,androidx.paging.PagingState)">load</a></code> asynchronously with load type <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code>, to update paginated content when the stream is initialized.</p>
</li>
<li>
<p><code><a href="/reference/androidx/paging/RemoteMediator.InitializeAction.SKIP_INITIAL_REFRESH.html">SKIP_INITIAL_REFRESH</a></code> to wait for a refresh request from the UI before dispatching a <code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#load(androidx.paging.LoadType,androidx.paging.PagingState)">load</a></code> with load type <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code>.</p>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="load(androidx.paging.LoadType, androidx.paging.PagingState)"></a><a name="load-androidx.paging.LoadType-androidx.paging.PagingState-"></a>
<h3 class="api-name" id="load(androidx.paging.LoadType,androidx.paging.PagingState)">load</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;<a href="/reference/androidx/paging/RemoteMediator.MediatorResult.html">RemoteMediator.MediatorResult</a>&nbsp;<a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#load(androidx.paging.LoadType,androidx.paging.PagingState)">load</a>(<a href="/reference/androidx/paging/LoadType.html">LoadType</a>&nbsp;loadType,&nbsp;<a href="/reference/androidx/paging/PagingState.html">PagingState</a>&lt;Key,&nbsp;Value&gt;&nbsp;state)</pre>
<p>Implement this method to load additional remote data, which will then be stored for the <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> to access. These loads take one of two forms:</p>
<ul>
<li>
<p>type == <code><a href="/reference/androidx/paging/LoadType.PREPEND.html">LoadType.PREPEND</a></code> / <code><a href="/reference/androidx/paging/LoadType.APPEND.html">LoadType.APPEND</a></code> The <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> has loaded a 'boundary' page, with a <code>null</code> adjacent key. This means this method should load additional remote data to append / prepend as appropriate, and store it locally.</p>
</li>
<li>
<p>type == <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code> The app (or <code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#initialize()">initialize</a></code>) has requested a remote refresh of data. This means the method should generally load remote data, and <b>replace</b> all local data.</p>
</li>
</ul>
<p>The runtime of this method defines loading state behavior in boundary conditions, which affects e.g., <code><a href="/reference/androidx/paging/LoadState.html">LoadState</a></code> callbacks registered to <code><a href="/reference/androidx/paging/PagingDataAdapter.html">androidx.paging.PagingDataAdapter</a></code>.</p>
<p>NOTE: A <code><a href="/reference/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">PagingSource.load</a></code> request which is fulfilled by a page that hits a boundary condition in either direction will trigger this callback with <code><a href="/reference/androidx/paging/LoadType.PREPEND.html">LoadType.PREPEND</a></code> or <code><a href="/reference/androidx/paging/LoadType.APPEND.html">LoadType.APPEND</a></code> or both. <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code> occurs as a result of <code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#initialize()">initialize</a></code> or if refresh is requested programmatically (e.g. in response to a pull to refresh action).</p>
<p>This method is never called concurrently <em>unless</em><a href="[Pager.flow]">Pager.flow</a> has multiple collectors. Note that Paging might cancel calls to this function if it is currently executing a <code><a href="/reference/androidx/paging/LoadType.PREPEND.html">LoadType.PREPEND</a></code> or <code><a href="/reference/androidx/paging/LoadType.APPEND.html">LoadType.APPEND</a></code> and a <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code> is requested. In that case, <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code> has higher priority and will be executed after the previous call is cancelled. If the <code>load</code> call with <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code> returns an error, Paging will call <code>load</code> with the previously cancelled <code><a href="/reference/androidx/paging/LoadType.APPEND.html">LoadType.APPEND</a></code> or <code><a href="/reference/androidx/paging/LoadType.PREPEND.html">LoadType.PREPEND</a></code> request. If the <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code> succeeds, it won't make the <code><a href="/reference/androidx/paging/LoadType.APPEND.html">LoadType.APPEND</a></code> or <code><a href="/reference/androidx/paging/LoadType.PREPEND.html">LoadType.PREPEND</a></code> requests unless they are necessary again after the <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code> is applied to the UI.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/androidx/paging/RemoteMediator.MediatorResult.html">RemoteMediator.MediatorResult</a></code></td>
<td width="100%">
<p><code><a href="/reference/androidx/paging/RemoteMediator.MediatorResult.html">MediatorResult</a></code> signifying what <code><a href="/reference/androidx/paging/LoadState.html">LoadState</a></code> to be passed to the UI, and whether there's more data available.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/androidx/paging/LoadType.html">LoadType</a>&nbsp;loadType</code></td>
<td width="100%">
<p><code><a href="/reference/androidx/paging/LoadType.html">LoadType</a></code> of the boundary condition which triggered this callback.</p>
<ul>
<li>
<p><code><a href="/reference/androidx/paging/LoadType.PREPEND.html">LoadType.PREPEND</a></code> indicates a boundary condition at the front of the list.</p>
</li>
<li>
<p><code><a href="/reference/androidx/paging/LoadType.APPEND.html">LoadType.APPEND</a></code> indicates a boundary condition at the end of the list.</p>
</li>
<li>
<p><code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code> indicates this callback was triggered as the result of a requested refresh - either driven by the UI, or by <code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#initialize()">initialize</a></code>.</p>
</li>
</ul>
</td>
</tr>
<tr>
<td><code><a href="/reference/androidx/paging/PagingState.html">PagingState</a>&lt;Key,&nbsp;Value&gt;&nbsp;state</code></td>
<td width="100%">
<p>A copy of the state including the list of pages currently held in memory of the currently presented <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> at the time of starting the load. E.g. for load(loadType = END), you can use the page or item at the end as input for what to load from the network.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="loadSingle(androidx.paging.LoadType, androidx.paging.PagingState)"></a><a name="loadSingle-androidx.paging.LoadType-androidx.paging.PagingState-"></a>
<h3 class="api-name" id="loadSingle(androidx.paging.LoadType,androidx.paging.PagingState)">loadSingle</h3>
<pre class="api-signature no-pretty-print">public&nbsp;abstract&nbsp;<a href="/reference/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;<a href="/reference/androidx/paging/RemoteMediator.MediatorResult.html">RemoteMediator.MediatorResult</a>&gt;&nbsp;<a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#loadSingle(androidx.paging.LoadType,androidx.paging.PagingState)">loadSingle</a>(<a href="/reference/androidx/paging/LoadType.html">LoadType</a>&nbsp;loadType,&nbsp;<a href="/reference/androidx/paging/PagingState.html">PagingState</a>&lt;Key,&nbsp;Value&gt;&nbsp;state)</pre>
<p>Implement this method to load additional remote data, which will then be stored for the <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> to access. These loads take one of two forms:</p>
<ul>
<li>
<p>type == <code><a href="/reference/androidx/paging/LoadType.PREPEND.html">LoadType.PREPEND</a></code> / <code><a href="/reference/androidx/paging/LoadType.APPEND.html">LoadType.APPEND</a></code> The <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> has loaded a 'boundary' page, with a <code>null</code> adjacent key. This means this method should load additional remote data to append / prepend as appropriate, and store it locally.</p>
</li>
<li>
<p>type == <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code> The app (or <code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#initialize()">initialize</a></code>) has requested a remote refresh of data. This means the method should generally load remote data, and <b>replace</b> all local data.</p>
</li>
</ul>
<p>The runtime of this method defines loading state behavior in boundary conditions, which affects e.g., <code><a href="/reference/androidx/paging/LoadState.html">LoadState</a></code> callbacks registered to <code><a href="/reference/androidx/paging/PagingDataAdapter.html">androidx.paging.PagingDataAdapter</a></code>.</p>
<p>NOTE: A <code><a href="/reference/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">PagingSource.load</a></code> request which is fulfilled by a page that hits a boundary condition in either direction will trigger this callback with <code><a href="/reference/androidx/paging/LoadType.PREPEND.html">LoadType.PREPEND</a></code> or <code><a href="/reference/androidx/paging/LoadType.APPEND.html">LoadType.APPEND</a></code> or both. <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code> occurs as a result of <code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#initialize()">initialize</a></code>.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;<a href="/reference/androidx/paging/RemoteMediator.MediatorResult.html">RemoteMediator.MediatorResult</a>&gt;</code></td>
<td width="100%">
<p><code><a href="/reference/androidx/paging/RemoteMediator.MediatorResult.html">MediatorResult</a></code> signifying what <code><a href="/reference/androidx/paging/LoadState.html">LoadState</a></code> to be passed to the UI, and whether there's more data available.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/androidx/paging/LoadType.html">LoadType</a>&nbsp;loadType</code></td>
<td width="100%">
<p><code><a href="/reference/androidx/paging/LoadType.html">LoadType</a></code> of the boundary condition which triggered this callback.</p>
<ul>
<li>
<p><code><a href="/reference/androidx/paging/LoadType.PREPEND.html">LoadType.PREPEND</a></code> indicates a boundary condition at the front of the list.</p>
</li>
<li>
<p><code><a href="/reference/androidx/paging/LoadType.APPEND.html">LoadType.APPEND</a></code> indicates a boundary condition at the end of the list.</p>
</li>
<li>
<p><code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType.REFRESH</a></code> indicates this callback was triggered as the result of a requested refresh - either driven by the UI, or by <code><a href="/reference/androidx/paging/rxjava2/RxRemoteMediator.html#initialize()">initialize</a></code>.</p>
</li>
</ul>
</td>
</tr>
<tr>
<td><code><a href="/reference/androidx/paging/PagingState.html">PagingState</a>&lt;Key,&nbsp;Value&gt;&nbsp;state</code></td>
<td width="100%">
<p>A copy of the state including the list of pages currently held in memory of the currently presented <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> at the time of starting the load. E.g. for load(loadType = END), you can use the page or item at the end as input for what to load from the network.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>