title: Getting the latest data from a promise returning service called repeatedly
body: <p>I have an angular service that returns a promise for data obtained from a server. This data is requested multiple times in a fixed interval to keep the display up to date. The response can sometimes be quite slow (up to 10 seconds), and if two requests overlap and the first one responds last I'll get out of date information displayed in the app. The timelines would be something like:</p>
  
  <pre><code>- first request
  Req ---------------------&gt; Res
  - second request
        Req -------&gt; Res
  </code></pre>
  
  <p>Currently I keep a counter of the request and make the .then function close over it and discard the data if it is too old. I wonder if one of the promise libraries out there already does it or if there is a standard way to do it.</p>
  
  <p>I've also though about adding the response timestamp to the returned object, or somehow using something like RxJs but I haven't used it to know if it applies somehow.</p>