NPM
ользую следующий код для таймера:
export class TimerService {
private ticks: number = 0;
private seconds: number = 0;
private timer;
constructor(seconds: number) {
this.seconds = seconds;
this.timer = Observable.timer(2000, 1000);
this.timer.subscribe(t => {
this.ticks = t;
this.disactivate();
});
}
private disactivate() {
if (this.ticks === this.seconds) {
this.timer.dispose();
}
}
}
Когда я пытаюсь остановить таймер в строке:
this.timer.dispose(); // this.timer.unsubscribe();
Это не работает для меня