title: Cancellable NGRX service polling in a Effect
body: <p>How does one poll a service with an effect that stops polling until the returned value of service meets a condition OR the total duration exceeds a timeout threshold? </p>
  
  <p>For example: A backend system is generating a resource, a frontend application can check whether that resource is available by calling a REST api call which returns a boolean. In my NGRX application I would like to poll every 200 ms this api call until this api call returns the boolean true OR the total polling duration exeeds the threshold of 10000 ms.  </p>
  
  <p>The following code samples shows a polling mechanism, however, this polling cannot be cancelled nor has a timeout. How is this done? </p>
  
  <pre><code>import { Observable } from 'rxjs/Observable';
  import 'rxjs/add/observable/of';
  import 'rxjs/add/observable/timer';
  import 'rxjs/add/operator/catch';
  import 'rxjs/add/operator/map';
  import 'rxjs/add/operator/switchMap';
  
  @Effect()
  pollEffect$: Observable&lt;Action&gt; = this.actions$
    .ofType(tasksActions.ActionTypes.START_POLLING)
    .switchMap(() =&gt; Observable.timer(0, 200)
      .switchMap(() =&gt; this.myBackendService.getAvailability().map(response =&gt; 
         return taskActions.ActionTypes.UpdateValue(response))
      )
    );
  </code></pre>