Re: InedxedDB events : misconception?

On Mon, Apr 22, 2013 at 9:56 AM, Michaël Rouges
<michael.rouges@gmail.com> wrote:
>
> Hum ... thank you for this answer, but ...
>
> Are you sure there is no possibility that the application is completed
> before adding events?
>
> I find it hard to perceive how it couldn't happen.

Do you also worry that if you wrote:

x = 0;
setTimeout(function() { x = 1; }, 0);
console.log(x);
console.log(x);
console.log(x);
console.log(x);
console.log(x);
console.log(x);

that there's a risk that you'd get a few 0's in the log, but at some
point it would switch to logging 1's?

No developer that I've talked to think that that could happen in JS.
And it can't. It's clear to everyone that you'll only get 0's. The
reason is that JS is single threaded and the setTimeout callback is
run asynchronously.

It's the same thing in IDB. The .onsuccess property is triggered
asynchronously which means that it couldn't happen in the middle of
your execution.

/ Jonas

Received on Monday, 22 April 2013 18:51:14 UTC