I have the following countdown:
userClick=new Subject()
resetCountdown(){this.userClick.next()}
setCountDown() {
let counter = 5;
let tick = 1000;
this.countDown = timer(0, tick)
.pipe(
take(counter),
map(() => --counter),
takeUntil(this.userClick),
finalize(() => {
if (this.currentQuestionNumber < this.questionsToAsk)
this.showNextQuestion();
else {
this.endQuiz();
}
})
);
}
When takeUntil(this.userClick)
occurs, I do not want finalize
to be executed. Is there any possibility to achieve that? I only want finalize
to be executed when the countdown has reached 0
and was not interrupted before by takeUntil