[whatwg] ProgressEvents for Images

On 2/23/12 5:23 PM, "Boris Zbarsky" <bzbarsky at MIT.EDU> wrote:

>On 2/23/12 7:38 PM, Hans Muller wrote:
>>    Hans - It's useful if you want your listener to run after all of the
>>load listeners have run, and code that you haven't written adds its own
>>load listeners.
>I strongly urge you to read
>Or put another way, what will you do a year after this is standardized,
>when the code that you haven't written is adding loadend listeners?

If loadend listeners were used as intended and not as a proxy for "code to
run last,
after everything else", then years from now I'll carry on using them to
run code
after the load and error listeners have run. That said, I understand your
To use loadend in the scenario I posed, you have to know that the function
calling is doing something with load/error listeners that you'd like to
with your own listener.

>>The problem with using setTimeout() to schedule a listener to run after
>>all of image's load listeners has run is that you've got to guess how
>>loading the image (or failing to load the image) and running its
>>will take.
>No, you don't.  You simply do:
>   function delayedLoadStuff() {
>     setTimeout(doTheThingIWant, 0);
>   }
>   img.addEventListener("load", delayedLoadStuff, false);
>   img.addEventListener("error", delayedLoadStuff, false);

Good point, although this approach seems to lead to the very same dystopia
were just warning about.  If everyone tries to schedule their image
listener last
with setTimeout()...

- Hans

Received on Friday, 24 February 2012 09:36:58 UTC