title: Unsubscribe to timer not possible if component destroyed quickly
body: <p>I have a component that make a loop api calls using rxjs <code>timer</code> operator</p>
  <p>My problem is that if the component get destroyed ( for example close the modal ) within 5 seconds I get a loop calls seconds after ( May be the timer get not unsubscribed because it does not return yet a subscription )</p>
  <p>What I would like to do is that timer does not make loop calls if I destroy component within 5 seconds.</p>
  <pre><code>import {Component, OnInit, OnDestroy} from '@angular/core';
  import { Observable, Subscription, timer } from 'rxjs/Rx';
  
  @Component({
      templateUrl: 'app/pages/CurrentRuns/currentruns.component.html'
  })
  export class CurrentRunsComponent implements OnInit, OnDestroy {
  
      // Subscription object
      private sub: Subscription;
  
      ngOnInit() {
          this.sub= timer(firstcheckVal, 2500)
            .pipe(switchMap(() =&gt; this.testService.getTestdata())).subscribe(data =&gt; {
               ...
            }
  
      ngOnDestroy(){
          console.log(&quot;Destroy timer&quot;);
          // unsubscribe here
          if (this.sub) {
            this.sub.unsubscribe();
          }
      }
  }
  </code></pre>