Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Intent to implement and ship: DOMRequest.then

40 views
Skip to first unread message

Ehsan Akhgari

unread,
Sep 27, 2014, 11:55:50 AM9/27/14
to dev-pl...@lists.mozilla.org, dev-gaia
Summary:

DOMRequest is an API that we implemented before DOM promises were
available, and it is superseded by Promise. It is, however, incompatible
with the Promise API in three main ways: its API surface is completely
different, it uses DOM events to dispatch success/error events, and its
events are dispatched synchronously. Currently DOMRequest is used by a lot
of APIs on Firefox OS.

We would like to start the process of transitioning some of these APIs to
use Promises. As a first step to ease the migration pass, I'm implementing
a DOMRequest.then() method which is compatible with Promise.then(), and is
intended to be a drop-in replacement. DOMRequest.then() returns a Promise,
and calls its resolve or reject callbacks asynchronously. The returned
promise can be chained with other Promises in the usual way.

Our hope is that with this implemented, we are able to treat the DOMRequest
objects returned from the APIs above as Promises by calling .then() on
them. This will hopefully enable us to make those APIs return a Promise in
the future without breaking the code that uses them. It will also help the
consumers of those APIs to be able to use Promises throughout their code
without having to worry about DOMRequest.

Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=839838

Link to standard: DOMRequest is a Mozilla specific API that has no
corresponding standard.

Platform coverage: everywhere.

Estimated or target release: Firefox 35, Firefox OS 2.2.

Preference behind which this will be implemented: The patch is quite
simple, and the implementation is done using Promise internally, which is a
shipped and well-tested feature, so I don't think it's worth hiding this
one method behind a preference.

Note that once the patch is reviewed, I plan to land it on trunk, enabled
by default.

Cheers,
--
Ehsan

David Rajchenbach-Teller

unread,
Sep 27, 2014, 3:56:52 PM9/27/14
to Ehsan Akhgari, dev-pl...@lists.mozilla.org, dev-gaia
Speaking only for myself: I have been waiting for this for, well,
basically since IndexedDB landed. I am a bit worried by this being
Mozilla-specific, though.

If my memory serves, W3C specifies the IDBRequest interface which, in
the scope of IndexedDB, is essentially the same as DOMRequest. Is this
change compatible with whatever is in store for IDBRequest?

Cheers,
David

On 27/09/14 17:54, Ehsan Akhgari wrote:
> Summary:
>
> DOMRequest is an API that we implemented before DOM promises were
> available, and it is superseded by Promise. It is, however, incompatible
> with the Promise API in three main ways: its API surface is completely
> different, it uses DOM events to dispatch success/error events, and its
> events are dispatched synchronously. Currently DOMRequest is used by a lot
> of APIs on Firefox OS.
>

--
David Rajchenbach-Teller, PhD
Performance Team, Mozilla

signature.asc

Jonas Sicking

unread,
Sep 27, 2014, 5:23:31 PM9/27/14
to David Teller, Ehsan Akhgari, dev-gaia, dev-platform
On Sep 27, 2014 12:57 PM, "David Rajchenbach-Teller" <dte...@mozilla.com>
wrote:
>
> Speaking only for myself: I have been waiting for this for, well,
> basically since IndexedDB landed. I am a bit worried by this being
> Mozilla-specific, though.
>
> If my memory serves, W3C specifies the IDBRequest interface which, in
> the scope of IndexedDB, is essentially the same as DOMRequest. Is this
> change compatible with whatever is in store for IDBRequest?

There are no plans currently to make any changes to IDBRequest or IndexedDB
in general.

Like you point out, that would affect interoperability with other browsers,
and may not be compatible with future IDB changes.

Additionally, IDB's current transaction handling isn't really compatible
with the spirit of the Promise spec. So larger changes would be needed to
IDB in order to add promises to it.

/ Jonas
0 new messages