Re: Are there any plans to make IndexedDB and promises play nice?

On Thu, Apr 16, 2015 at 12:04 AM, Jeremy Scheff <jdscheff@gmail.com> wrote:
> Currently, wrapping IndexedDB in promises is a perilous task. Pun intended,
> since the sticking point seems to be the distinction between microtasks and
> macrotasks. See http://stackoverflow.com/q/28388129/786644 for an example.
> Basically, it's not clear whether resolving a promise should auto-commit a
> transaction or not. Behavior varies across browsers and promise libraries,
> and I don't even know what the "correct" behavior actually is.

Part of the problem is that the correct behavior is not defined in
detail. ECMAScript defines a Job Queue. HTML defines an event loop.
The idea is that as part of HTML's event loop, promises integrate as
microtasks. HTML's event loop would basically deplete the Job Queue
each task. However, this is not defined because the exact integration
with the model ECMAScript landed on is rather cumbersome. It would be
much easier if ECMAScript queued Jobs to the host environment along
with some metadata.


> Although having the IndexedDB API completely redone in promises would be
> nice, I understand that may be too big of a change to be feasible.

I believe that is also impossible due to the mismatch between
transaction semantics and promise semantics.


-- 
https://annevankesteren.nl/

Received on Thursday, 16 April 2015 13:04:32 UTC