You do not need RxJS for this. You can use the good old setTimeout:
initiateTimer() {
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(this.showPopup.bind(this), 60 * 60 * 1000);
}
If you really have to use RxJS, you can:
initiateTimer() {
if (this.timerSub) {
this.timerSub.unsubscribe();
}
this.timerSub = Rx.Observable.timer(60 * 60 * 1000)
.take(1)
.subscribe(this.showPopup.bind(this));
}
source
share