[whatwg] Progress Events "done" event

Křištof Želechovski giecrilj at stegny.2a.pl
Tue Sep 11 12:38:54 PDT 2007

Why is 
	xhr.addEventListener("done", callCompleteHandler, false);
more concise than
	add_done_hook(xhr, cch)?
The former line is actually longer.

While English does not have loops, it has quantifiers and relations that are
quite convenient for most common purposes.  I do not think English with
loops would be cool.  C has loops but it is not cool at all.  It is
doubleplusuncool.  Declarative languages are, in general, cooler than
functional ones.  You need special languages for special purposes and there
is nothing weird about this fact.


-----Original Message-----
From: Garrett Smith [mailto:dhtmlkitchen at gmail.com] 
Sent: Monday, September 10, 2007 11:33 PM
To: Křištof Želechovski
Cc: whatwg at whatwg.org; chaals at opera.com
Subject: Re: [whatwg] Progress Events "done" event

On 8/27/07, Křištof Želechovski <giecrilj at stegny.2a.pl> wrote:
> Remember that JavaScript is a programming language after all.  You can use
> loop to get rid of the repetitions.
> Start from
> var done = ["load", "error", "abort"]...
> and apply the closure image.aEL(?, hPB, false) to it.
> Sincerely,
> Chris
That is true, in fact, it would also be possible to use Array.forEach
on that array.

The disadvantage is that it still invites code repetition. It is less

On the contrary:

xhr.addEventListener("done", callCompleteHandler, false);
function callCompleteHandler(e) {


Translates the use case to code quite naturally.

I like to make these examples that are conceptually similar:

"I'm going to call my friend and then I'm going to the dry cleaner."

"I'm going to call my friend and if she's not available, after that,
I'm going to the dry cleaner and if the call failed, after that, I'm
going to the dry cleaner, and if we talk for a bit, after that...

You get the point. English doesn't have loops or generators (hey
wouldn't that be cool!).

My point is that having a done event is more concise and makes
realizing the use-case requirement to code more explicit.


> -----Original Message-----
> From: whatwg-bounces at lists.whatwg.org
> [mailto:whatwg-bounces at lists.whatwg.org] On Behalf Of Garrett Smith
> Sent: Sunday, August 26, 2007 8:25 AM
> To: whatwg at whatwg.org
> Cc: chaals at opera.com
> Subject: [whatwg] Progress Events "done" event
> ==========================================
> function showImage(imageHref) {
> ...
> // remove the progress bar when done.
>        image.addEventListener("load", hideProgressBar, false);
>        image.addEventListener("error", hideProgressBar, false);
>        image.addEventListener("abort", hideProgressBar, false);
> }
> ==========================================
> This is somewhat verbose. Clearly, the author is forced to repeat
> himself when all he really wants to do is hide the progress bar after
> the call is done.

Programming is a collaborative art.

More information about the whatwg mailing list