title: Polling with RxJS that can recover missed events
body: <p>I am trying to use RxJS to poll for events. However, I only have access to one function, which is <code>getEvent()</code>. I can do 2 things with the <code>getEvent</code> function:</p>
  
  <ol>
  <li><code>getEvent("latest")</code> — this will give me the latest event object</li>
  <li><code>getEvent(eventId)</code> - I pass in an integer and it will give me the event object corresponding to the <code>eventId</code>.</li>
  </ol>
  
  <p>Event IDs always increment from 0, but the problem is, if my polling interval isn't small enough, I might miss events.</p>
  
  <p>For example, if I do a <code>getEvent("latest")</code> and I get an event that has an ID of 1, that's great. But if the next time I call it, I get an ID of 3, I know that I missed an event.</p>
  
  <p>In this case, I want to use a higher-order observable to call <code>getEvent(2)</code> and <code>getEvent(3)</code> so that the consumer of the stream I am creating won't have to worry about missing an event.</p>
  
  <p>Right now, all I have is something like this:</p>
  
  <pre><code>timer(0, 500).pipe(
    concatMap(() =&gt; from(getEvent("latest"))
  )
  </code></pre>
  
  <p>For some context, I'm working off of this blogpost: <a href="https://itnext.io/polling-using-rxjs-b56cd3531815" rel="nofollow noreferrer">https://itnext.io/polling-using-rxjs-b56cd3531815</a></p>