[whatwg] Request: window.postMessage should be async

Aaron Boodman aa at google.com
Sun Apr 6 01:52:41 PDT 2008


Here is one more point on the async vs sync thing.

In my opinion, one of the most compelling reasons to make an API
synchronous instead of asynchronous is convenience. This is why I was
so passionate about having a synchronous database API: getting the
result of a call via a return value is much simpler conceptually than
getting it via a callback. I was rightfully proven wrong on this issue
-- blocking indefinitely on the UI thread is not worth the convenience
of a procedure-call style interface.

But as postMessage is currently spec'd, it is synchronous, but it does
not have the convenience of a procedure-call style interface. If you
send an iframe a message with postMessage, you don't get the result of
that message as a return value. You have to hook up a listener and
wait for it from a separate message.

Which brings me back to my previous question: what advantage is there
to the API being synchronous? We have on one hand authors with reasons
(however edge casey you may believe them to be) they would prefer the
API be asynchronous, but I have not heard any reason for it to be
synchronous. There doesn't seem to be any advantage to it.

- a



More information about the whatwg mailing list