title: angular 2 detect if any RxJS timer is running or not
body: <p>I am working on angular2 application. I have scheduler requirement that runs on period of pre-configured time.</p>
  
  <p>I have mainly 2 component in my application:</p>
  
  <p><strong>1: HomeComponent,
  2: MasterComponent.</strong></p>
  
  <p>My master component will always be there in browser, all other component are it's child component of it.</p>
  
  <p>Now I have added <code>RxJS timer</code> in <code>ngOnInit()</code>..</p>
  
  <p>Now when I go to HomeComponent, MasterComponent is out of scope and when I came back to MasterComponnent another times starts(already first is working).. So Now I have 2 timers.</p>
  
  <p>So want to detect if any times is running then not start otherwise start.</p>
  
  <p>I need to start times only when user logs in.</p>
  
  <p><strong>Master Component Code:</strong></p>
  
  <pre><code>ngOnInit() {
      let timer = Observable.timer(2000, 1000);
      timer.subscribe(this.printConsole);
  }
  
  printConsole() {
      console.log("ticks: " + new Date());
  }
  </code></pre>
  
  <p>is there anyway so in <strong>ngOnInit</strong> I can detect any Timer already running or not !</p>