Bug with clearTimeout()? #6030
Replies: 1 comment
-
Posted at 2018-04-03 by @gfwilliams If you have a problem with ESP8266 boards:
Posted at 2018-04-03 by SergeP Thank you.
And I think it depends on JS implementation does on all devices, not only ESP8266. Usually I try to test my code for Puck.JS with ESP8266 first, because it is much easier to connect peripherals to it and to send code to it as well - espruino-server falls each second connection and can not work together with EspruinoHub. Posted at 2018-04-03 by @MaBecker Hi SergeP, as Gordon pointed out: Guess you are looking for setInterval(). Posted at 2018-04-03 by AntiCat @MaBecker The documentation to setTimeout states:
To answer your question calling a function without an argument is identical to calling it with Posted at 2018-04-03 by @MaBecker mea culpa, how could I miss that 😳..... thanks to AntiCat Posted at 2018-04-04 by @gfwilliams Hi - sorry about the short reply earlier @sergep. You're totally correct that they're the same on different platforms. The two forum sections are mainly there for me - over half of Espruino's users are using it on non-official boards now, and I can't afford to provide the same level of support for those that I provide for the boards that I sell (it's also one less reason for people to buy a proper board :). I'd forgotten that you were using Puck.js as well. If you hit issues like this again feel free to post on the official boards page, but please check it on a Puck or official board first just in case :) In some cases it is possible to detect an It seems that making Posted at 2018-04-04 by Wilberforce
Seems like a clean solution. Posted at 2018-04-04 by AndrewWakeling My vote is making it behave consistently with the spec.
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/clearTimeout Passing undefined or no parameters to clearTimeout should do nothing. Posted at 2018-04-04 by AntiCat I vote for handling
Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters I believe adding a distinction between undefined and missing breaks the spec too. Posted at 2018-04-04 by opichals @AnticaT Thanks, exactly. @sergep @gfwilliams I don't think this is a bug but rather a feature that the Espruino cleanInterval() implementation deviates from the specified behaviour by cancelling all scheduled timeouts and intervals rather then doing nothing. That said unless we would like to change the behavior to comply to the spec which would break a lot of existing user code done specifically for Espruino (perhaps doable using some sort of deprecation mechanism). Posted at 2018-04-06 by @gfwilliams Hmm - I'm still not convinced that Ideally it'd be spec compliant but given there's so much code out there that uses it, and changing it to be spec compliant would just 'silently do nothing' which would just randomly stop Espruino code from working with no warning - I don't think going fully spec compliant is an option. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2018-04-03 by SergeP
If I call
all intervals set by setInterval() and all timeouts set by setTimeout() disappears.
Checked by 1v95 on ESP8266
Is it a bug?
Beta Was this translation helpful? Give feedback.
All reactions