W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2007

[whatwg] Progress Events "done" event

From: Weston Ruter <westonruter@gmail.com>
Date: Sun, 26 Aug 2007 16:50:31 +0900
Message-ID: <fb8299e10708260050k72d6d83am43f8b8b924fb4520@mail.gmail.com>
This proposal is similar to the callbacks that Prototype's
Ajax.Requestmakes available. Instead of a "done" event, it provides
the callback
"onComplete": http://prototypejs.org/api/ajax/options

On 8/26/07, Garrett Smith <dhtmlkitchen at gmail.com> wrote:
>
> I've noticed a case when developing Ajax apps that I often end up
> duplicating a call to hide "loading.gif" (for example) when the call
> is over.
> Progress Events
>
> http://dev.w3.org/cvsweb/~checkout~/2006/webapi/progress/Progress.html?rev=1.16&content-type=text/html;%20charset=iso-8859-1#XHR
>
> Helps facilitate that, however, I think I see a way that the use case
> could be better-accomodated. Here is a simple use-case that
> illustrates the problem:
>
> Author loads a large picture.
> While the picture is loading, the user sees a progress bar.
> When the call is done, the progress bar is hidden.
>
> Notice, the use case is not, "when the picture is loaded, remove the
> progress bar." Instead, it reads: "When the call is done, the progress
> bar is hidden."
>
> In this use case, the progress bar must be removed, whether the call
> is successful or not. If the call fails, the call is aborted, or the
> call is successful, the progress bar is hidden.
>
> To fulfill the use case, the author creates a function callFinished,
> for example:
>
> function callFinished( progressEvent ) {
>   // Remove loader bar.
> }
>
> Using the current proposal, the author adds an EventListener for load,
> to hide the progress bar when the image is done loading. However, the
> author must also add EventListeners for failure and success Events to
> remove the loader bar in those cases now.
>
> ==========================================
> 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.
>
> I see this as being analogous to "hang up the phone after the call is
> done." We all know how that works. It doesn't matter if the other
> person hung up on rudely, we both said goodbye, the line got cut off,
> the phone service was down -- the call is over. (digression)
>
> It would be useful to have a "done" event.
>
> The revised example, with a hypothetical "done" event:
>
>
> ==========================================
> function showImage( imageHref ) {
>        ...
> // remove the progress bar when done.
>        image.addEventListener("done", hideProgressBar, false);
> }
> ==========================================
>
>
> Garrett
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20070826/25b52b1c/attachment.htm>
Received on Sunday, 26 August 2007 00:50:31 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:36 UTC