title: How to handle loss of connection in Angular2 with RXJS HTTP when polling
body: <p>I have the following code (simplified for this post) - assume an initial call to <code>onStart()</code>.</p>
  
  <p>Running this works fine. If I lose the internet connection I get the <code>net::ERR_INTERNET_DISCONNECTED</code> error (as expected) <strong><em>but</em></strong> the polling stops.</p>
  
  <p>Clearly I am not handling any errors here as that is where I'm getting stuck. I'm not clear where I handle those errors and how? Do I need to call <code>startPolling()</code> again?</p>
  
  <p>I need the polling to continue even if there is no internet connection, so that on re-connection data is updated. Any advice please?</p>
  
  <pre><code>onStart() {
      this.startPolling().subscribe(data =&gt; {
          // do something with the data
      });
  }
  
  startPolling(): Observable&lt;any&gt; {
      return Observable
          .interval(10000)
          .flatMap(() =&gt; this.getData());
  }
  
  getData() {
      var url = `http://someurl.com/api`;
      return this.http.get(url)
          .map(response =&gt; {
              return response.json();
          });
  }
  </code></pre>
  
  <p>Thanks in advance.</p>