I need to ensure that 'this.breakCheck();' is called only once after the timeout is complete, not with every iteration. Right now I have it set up to call on each iteration, which works but is not ideal.
public startBreak(){
for(let i = this.breakSeconds; i > 0; i--){
this.$timeout(() =>{ this.breakSeconds -= 1; this.breakCheck();}, 1000 * i);
}
}
In a previous version, I had the function structured like this:
public startBreak(){
for(let i = this.breakSeconds; i > 0; i--){
this.$timeout(() =>{ this.breakSeconds -= 1;}, 1000 * i);
}
this.breakCheck();
}
The issue with the earlier setup was that 'startBreak()' was being triggered immediately by a click event before the timeout completed.
Appreciate any help or suggestions, thank you!