title: RXJS - SwitchMap or SwitchMapTo for resetting timer
body: <p>So I am new to RXJS. What I am trying to do is setup a session expiration timer, and when a user receives a modal prompt that their session is about to expire, if they click Continue, the timer is reset.</p>
  
  <p>I've been reading on switchMap and switchMapTo, but the examples I find use some kind of click event or mouse move event. My situation is, I don't want to refresh on a button click since I am validating a JWT. Upon successful validation of the JWT, I will then refresh the timer.</p>
  
  <p>I have a common library for users that sets up the timer like this:</p>
  
  <pre><code>private tick: Subscription;
  public tokenExpirationTime: Subject&lt;number&gt;;
  
    setupExpirationTimer():void {
      // Start the timer based on the expiration
      var expirationSeconds = this.expiration * 60;
      this.tick = Observable.timer(0, 1000).map(i =&gt; expirationSeconds - i).subscribe(x =&gt; {
        // Set the seconds in the user object
        this.tokenExpirationTime.next(x);
        console.log("TIMER: " + x);
      });
    }
  </code></pre>
  
  <p>Elsewhere in my code, I subscribe to the tokenExpirationTime (which is how I know what the current time is on the timer so I know when to show my popup).</p>
  
  <p>Ex.</p>
  
  <pre><code>this.user.tokenExpirationTime.subscribe(x =&gt; { ... });
  </code></pre>
  
  <p>I could be doing this all incorrectly, as I am new to this. I hope my explanation is clear, but let me know if not. Thank you for the help!</p>