Click handler is being executed from a different function even though that is not the currently running function

Click handler is being executed from a different function even though that is not the currently running function
0

#1

Steps to reproduce issue:(default session and break set to 20 seconds)

  1. Start timer by clicking within blue circle
  2. Session timer completes successfully.
  3. When breaktimer starts running clicking it to pause is calling click handler in runtimer function

How to prevent that from happening?
Also my code needs refactoring, any help on refactoring is appreciated too.


#2

Everytime you click the circle, you are resetting breakSeconds to 20 no matter if you are displaying session or break. So if you are in the break and you click it to pause, you already have set the breakSeconds to 20 and then again to 20 when you click to resume the timer. Actually, it appears you are running multiple timers at once, because every time the circle is clicked, you are use setInterval.


#3


Hi. Thanks for replying.
"Actually, it appears you are running multiple timers at once, because every time the circle is clicked, you are use setInterval."
How to prevent this from happening?
I have refactored my code to a single function which handles session and break.I am still running into an error where click handler within circle is called multiple times for a single click. I put an alert to test and you will notice it when break timer starts.
The number of alerts is increasing incrementally as I start and pause.