With bug 988122 landing soon, you'll now find a "Promise" object
available by default in the global scope of JavaScript modules.

However, this default implementation is still limited, and you're
strongly recommended to import Promise.jsm explicitly in new modules:

  Cu.import("resource://gre/modules/Promise.jsm");

This will give you a number of advantages, among others:
 - Errors don't risk disappearing silently (bug 966452)
 - Tests will fail if errors are accidentally uncaught (bug 976205)
 - You can inspect the current state in the debugger (bug 966471)
 - You can see registered "then" handlers (bug 966472)
 - You get better performance on long Promise chains

Promise.jsm and Promise are still interoperable from the functional
point of view, the difference is in the above non-functional
characteristics. Promise.jsm also has better performance due to the
fact that it avoids the JavaScript / C++ / JavaScript turnaround
time on chain resolution, with an optimized resolution loop handling,
but I don't think this performance part should prevent us from
migrating to C++ Promises when the other limitations are addressed.

Cheers,
Paolo
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to