On Monday, November 25, 2013 12:25:00 PM UTC-8, jsan...@gmail.com wrote: > Is there a consensus on removing Promise.jsm completely? As Benvie said, the > majority of work will be migrating over from `sdk/core/promise.js` (sync) to > the async Promise.jsm, which share APIs. Converting Promise.jsm to consume > DOM Promises is pretty straight forward, and would still give us our current > defer/all utilities, which are used extensively. > >
The spec provides all() and race(), and they should land in m-c soon [1]. Deferreds, while intuitive, offer no advantages over the new callback syntax. The callback syntax forces better code in most situations. In places where the 'deferred resolution out of Promise callback' pattern is required since the resolve/reject may happen at a different call site, it is easy to get a reference to the resolve/reject functions of the promise as member variables. FooUtil.prototype = { _rejectTransaction: null, beginTransaction: function() { return new Promise((resolve, reject) => { this._rejectTransaction = reject; asyncStuff(resolve); }); }, close: function() { if (transactionInProgress) { this._rejectTransaction("close() called!"); } } } [1]: https://bugzil.la/939332 As for promise utilities from other libraries, any library that conforms to the Promise/A+ spec can accept a DOM Promise and operate on it with no issue. I would like to get rid of Promise implementations that reimplement stuff in the spec, but I'm not against adding more utilities as PromiseUtils.jsm or similar if it is required. Nikhil _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform