title: How can I have a side-effect subscription that does not alter the stream?
body: <p>Scenario:</p>
  
  <p>I have a list of data (transactions for a business). This data is considered stale if the following two conditions are met:</p>
  
  <ul>
  <li>The user (UI/View) is subscribed to the data source (an <code>rx.Observable&lt;List&lt;Transaction&gt;&gt;</code>)</li>
  <li>>= 5 minutes have passed since the last network synchronization. This value is serialized and observed from the database.</li>
  </ul>
  
  <p>Note: if the UI/view is NOT subscribed to the data source, and >= 5 five minutes has passed, I do NOT want to sync fresh data (because no one is listening)</p>
  
  <p>Some details for the code sample below:</p>
  
  <ul>
  <li><code>data.observe()</code> returns <code>rx.Observable&lt;List&lt;Transaction&gt;&gt;</code></li>
  <li><code>void syncIfLast5Minutes()</code> will imperatively check if there has been a sync in the last five minutes - if not, then a new network request will be executed to fetch fresh data</li>
  </ul>
  
  <p>Now, I could easily do something like:</p>
  
  <pre><code>data.observe()
      .doOnSubscribe(transactions -&gt; syncIfLast5Minutes()
  </code></pre>
  
  <p>But this would only check if the data is stale on the initial subscription by the UI. If the UI is still subscribed to after 5 minutes, an automatic refresh won't trigger here (but I want it do).</p>
  
  <p>I am looking for a side-effect operator that will</p>
  
  <ul>
  <li>not affect the original stream</li>
  <li>subscribing starts a timer that will monitor when the data is stale (>= 5 minutes has passed)</li>
  <li>unsusbscribing cancels this timer</li>
  </ul>
  
  <p>Is there an idiomatic way in RxJava to achieve this reactively?</p>