Stop timer when use another app


#1

i have a gamer with a timer, when i use another app the timer still working i want the timer stop when i am not in the game how i can achieve that
this is the code

    this.timer=this.paragraph.timer;
      this.counter$ = Observable.timer(0, this.tick)
    .take(this.timer)
    .map(() => --this.timer).finally(() =>{  this.endTimer();});

i also tried this code

  // this.counter$ = timer(0,this.tick).pipe(
    //   take(this.timer),
    //   map(() => --this.timer)
    // ).finally(() =>{  this.endTimer();});

#2

Look into the pause and resume events.


#3

I tried it and its works​:heart_eyes::heart_eyes: