W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2015

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

From: Anne van Kesteren <annevk@annevk.nl>
Date: Thu, 16 Apr 2015 15:04:04 +0200
Message-ID: <CADnb78jUYJ7_HqsnQxwSeihfBsPTP=ybR9NF=WwFp6zDOkBthw@mail.gmail.com>
To: Jeremy Scheff <jdscheff@gmail.com>
Cc: WebApps WG <public-webapps@w3.org>
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.

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

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:31 UTC