W3C home > Mailing lists > Public > public-xformsusers@w3.org > May 2017

JavaScript event queuing

From: Erik Bruchez <erik@bruchez.org>
Date: Tue, 30 May 2017 22:13:49 -0700
Message-ID: <CAAc0PEUhNWH4xOa65Q-wRmHbMxCjqXP6tY7ip+k5FKZR+ggU=Q@mail.gmail.com>
To: "public-xformsusers@w3.org" <public-xformsusers@w3.org>
So based on [EventTarget.dispatchEvent()][1] and this [StackOverflow
answer][2], dispatching an event in JavaScript with
`EventTarget.dispatchEvent()` is synchronous. The method even returns
whether the default action was canceled.

This indicates to me that it is not unreasonable for our `xf:dispatch`
action to be synchronous by default (without a delay), although we can make
a case either way.

The way you delay events in JavaScript is by using a `setTimeout()` (or
maybe `Window.postMessage()`), and that explicitly adds the callback/the
message post to a queue.

-Erik

[1]
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent
[2]
https://stackoverflow.com/questions/15277800/is-dispatchevent-a-sync-or-an-async-function
Received on Wednesday, 31 May 2017 05:14:44 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:37:48 UTC