Fwd: Re: [whatwg] Progress Events "done" event

Forwarded and reply-to set to webapi-public, which is where you should  
send things you want actively considered for the W3C progress events spec.  
That's the group working on the spec.

I think there is enough detail left in the mail below for webAPI people to  
get this. The idea is that it might be helpful to add a "done" event that  
could be trapped instead of having to get the seperate possible events  
that mean you are done.

I'm inclined not to add a "done" event. It invites code repetition in the  
browser, which is not helpful in the case of mobile browsers. Also, I  
think the example doesn't take into account that where the load is  
aborted, or wherer there is an error, you often want to pass by some  
relevant function such as explain what happened before calling the code to  
clean up the progress bar.

Since progress events are used by other specs, they can add a done if they  
really want. But it turns out that for example XHR has onreadystate change  
which you can use to get the same info.

What do others think?

Cheers

Chaals

------- Forwarded message -------
From: "Garrett Smith" <dhtmlkitchen@gmail.com>
To: "Křištof Želechovski" <giecrilj@stegny.2a.pl>
Cc: whatwg@whatwg.org, chaals@opera.com
Subject: Re: [whatwg] Progress Events "done" event
Date: Mon, 10 Sep 2007 23:33:20 +0200

On 8/27/07, Křištof Želechovski <giecrilj@stegny.2a.pl> wrote:
> Remember that JavaScript is a programming language after all.  You can  
> use a
> 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  
concise.

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."
vs.

"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.

Garrett

> -----Original Message-----
> From: whatwg-bounces@lists.whatwg.org
> [mailto:whatwg-bounces@lists.whatwg.org] On Behalf Of Garrett Smith
> Sent: Sunday, August 26, 2007 8:25 AM
> To: whatwg@whatwg.org
> Cc: chaals@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.
>
>
>
>
>



-- 
   Charles McCathieNevile, Opera Software: Standards Group
   hablo español  -  je parle français  -  jeg lærer norsk
chaals@opera.com   http://snapshot.opera.com - Kestrel (9.5α1)

Received on Tuesday, 11 September 2007 03:57:18 UTC