- From: Joseph Pecoraro <pecoraro@apple.com>
- Date: Sun, 27 Feb 2011 12:51:12 -0800
- To: public-webapps@w3.org
- Message-Id: <9CDD60BA-B0CC-4D2E-BDAE-0EE77F2BEBBF@apple.com>
Whenever I see the following snippet I never remember if its synchronous or asynchronous and I have to look it up:
    xhr.open('GET', 'example.html', false);
I think it would be much more readable if there were constants for Synchronous / Asynchronous:
    xhr.open('GET', 'example.html', XMLHttpRequest.SYNC);
If authors wanted to "start using it now", they could add the flags themselves:
    XMLHttpRequest.SYNC = false;
    XMLHttpRequest.ASYNC = true;
... or they could do something like the following (since I think undefined may become the default value asynchronous):
    xhr.open('GET', 'example.html', XMLHttpRequest.SYNC || false);
This gets especially hairy when the user + password parameters are needed, and there is a "magic" boolean in the middle:
http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#the-open-method
Suggested values would be SYNC/ASYNC matching the spec's "async" boolean name, or the longer SYNCHRONOUS/ASYNCHRONOUS.
Is this something that would be considered, or is it so easy for authors to make it clear, with comments or variable names, that it is not worth it? Maybe I just need to remember what that boolean means!
- Joseph Pecoraro
Received on Sunday, 27 February 2011 20:51:50 UTC