settimeout function is not working well #313
Replies: 2 comments
-
Posted at 2014-09-03 by @gfwilliams What I think might be happening is that setTimeout gets called lots and never cancelled:
So for instance if you press the button lots, and then 5 seconds after you started, you start pressing it again the original timers that have been added will start to expire and will cause the strange behaviour. Why not try moving setTimeout so it only gets called once:
I'm not sure why it would have worked on a website - personally I'd have thought that it would have the same problem. Or if you actually want there to be a 5 second pause between presses (rather than after the first press) then you could actually just cancel the timer and re-set it.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-04 by Bert-Holland Thanks for your solution Gordon! Now that you explain me the bug that the setTimeOut called over and over again, i see the problem. But anyway, thanks a lot! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2014-09-02 by Bert-Holland
Hi people.
I have some troubles with the settimeout function.
I have made a switch that an action can happen only one in the time of an interval.
This cod is not specially meant for the espruino but i have tried this in the browser implemented in a website.
The code works pretty well but if i click repeatedly fast, then the code ignores the if condition.
Do i have made a mistake in this codeblock?
Beta Was this translation helpful? Give feedback.
All reactions