Countdown not working when take value from storage

hi every one i have spelling game for Arabic language where i have timer this timer i take it’s value from another class the timer work but when it end nothing happens the timer is 0 but finally not working also when i get out of app the timer still working in the background here is the code :
this is inside constructor'timerset').then((val)=>

    this.counter$ = Observable.timer(0,this.tick).pipe(
      map(() => --this.timer)
     ).finally(() =>{  


    this.answerAudio("timefinish","انتهي الوقت")



When you say “I take its value from another class”, I’m hearing that you’re using storage to communicate between parts of your app while it’s running. That’s a bad idea for a few reasons: synchronization hassle and needless user delay being primary. The only reason storage should come into play here is if you’re doing something like pausing and resuming the app and wanting to reuse whatever the timer state was at pause at resume time.

Your map has side effects, which is also not good. map is for transforming values emitted by an Observable, and that’s all it should do. If you want to keep using map and convert a countup operator into a countdown, you could do something like this:

let start = 100;
let countdown$ = interval(1000).pipe(take(start), map((n: number) => start - n));

If you want to be decrementing a property as you are now (not a style I would recommend in this case, but that’s a longer philosophical argument), then I would suggest using the tap operator instead of map.

What appears to be the central problem, given what you’ve written here, is that I’m not ever seeing anywhere that you are subscribing to counter$. In RxJS-land, the proverbial falling tree in the forest generally doesn’t make a sound unless somebody is listening to it.

first thank u for ur replay, i need to get this value from storage our app is educational app we need the parents set the time for their kids so i need to get the time from storage

i tried the code and give me this error even when i set import “rxjs/add/observable/interval”;

I guess I don’t know what RxJS version you’re using, but I import interval from rxjs (v6.5.3).

can u give me the import
their is the rxjs version