bug in example

View: New views
2 Messages — Rating Filter:   Alert me  

bug in example

by Bennet Yee (余仕斌) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi,

my apologies in advance if this has already been noted.  i recently
was introduced to  http://dev.w3.org/2006/webapi/FileAPI/ and noticed
that the first example appears to have the following race condition:
in getAsText, reader.readAsText occurs before any event callbacks are
set, so if the completion occurs after read.readAsText(...) and
reader.onprogress = ..., .onload = ... etc, then no callbacks will
ever get called.  or am i misunderstanding the way the callbacks are
supposed to work -- i.e., they're level triggered and not edge
triggered?  (i'd imagine onprogress shouldn't be level triggered.)

-bsy
--
bennet s yee
i usually don't capitalize due to mild tendonitis



Re: bug in example

by Ian Hickson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 4 Nov 2009, Bennet Yee (ä½~Yä»~Uæ~V~L) wrote:

>
> my apologies in advance if this has already been noted.  i recently was
> introduced to http://dev.w3.org/2006/webapi/FileAPI/ and noticed that
> the first example appears to have the following race condition: in
> getAsText, reader.readAsText occurs before any event callbacks are set,
> so if the completion occurs after read.readAsText(...) and
> reader.onprogress = ..., .onload = ... etc, then no callbacks will ever
> get called.  or am i misunderstanding the way the callbacks are supposed
> to work -- i.e., they're level triggered and not edge triggered?  (i'd
> imagine onprogress shouldn't be level triggered.)
Events are asynchronous, so they never trigger before the script has
finished (including setting the event handler attributes).

HTH,
--
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'