Skip to content
Discussion options

You must be logged in to vote

Timer.clear() is not clearInterval(). The documentation accurately describes the behavior. The unit tests confirm the expected error on double close.

Are you suggesting that Timer.clear() adopt the silent failure behavior of clearInterval()? That is convenient for emulation of clearInterval(). It is inconsistent with the general behavior of the Moddable SDK (and ECMAScript) which is to throw an exception on invalid object. There is an exception to this on close() which is generally safe to call multiple time (and clear is analogous to close).

To try that, update the start of xs_timer_clear:

void xs_timer_clear(xsMachine *the)
{
	modTimerScript ts;

	if (0 == xsmcArgc)
		return;

	modTimer t…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by stc1988
Comment options

You must be logged in to vote
1 reply
@phoddie
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants