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
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to