title: RxJava2 have remote data override local data in Observable
body: <p>Currently I have a method in a repository class which fetches data from both a local cache and a remote API.</p>
  
  <pre><code>public Observable&lt;List&lt;Items&gt;&gt; getItemsForUser(String userId {
      return Observable.concatArrayEager(
              getUserItemsLocal(userId), // returns Observable&lt;List&lt;Items&gt;&gt;
              getUserItemsRemote(userId) // returns Observable&lt;List&lt;Items&gt;&gt;
      );
  }
  </code></pre>
  
  <p>Currently, the method fetches the local data first (which may be outdated) and returns it, then updates it with the fresh data from the remote API.</p>
  
  <p>I want to change the implementation to use <code>Observable.merge</code> so that if the remote API request completes first, that data gets shown first. However, if I just use <code>Observable.merge</code> I'm concerned that the local database request may return stale data, which will then overwrite the fresh data from the remote. </p>
  
  <p>Basically, I want something like:</p>
  
  <pre><code>public Observable&lt;List&lt;ShoutContent&gt;&gt; getItemsForUser(String userId, ErrorCallback errorCallback) {
      return Observable.merge(
              getUserItemsRemote(userId),
              getUserItemsLocal(userId)
                  .useOnlyIfFirstResponse()
  }
  </code></pre>
  
  <p>So if the remote API request completes first, then that response is the only one that gets returned. But if the local request completes first, I want to return that, and then return the remote request once it is completed. Does RxJava have anything like this built in?</p>
  
  <p>Edit: I would like to add that <code>getUserItemsRemote</code> does update the local database when the Observable emits, but I don't think that I can ensure that the database will be updated before the local request completes, which leaves the possibility that the local request will respond with stale data.</p>