On 22/04/2014 05:24, Joshua Cranmer 🐧 wrote:
For more specific explanation then:
I have a (non-negotiably) JS-implemented XPCOM service called the Folder
Lookup Service. I want to add an API to it called getOrCreateFolder that
returns a Promise<nsIMsgFolder>. I have non-negotiable C++ code that
wants to call this method, and do something when the promise is resolved
or rejected.

Dumb question time: why not provide an XPIDL'd alternative JS wrapper method (getOrCreateFolderForNativeConsumers or whatever) that takes two nsIRunnables or equivalent XPIDL'd C++ callback wrappers, and wrapping the getOrCreateFolder method with

.then((x) => successRunnable.run(x), (x) => failRunnable.run(x));

?

That requires 0 API changes on the JSAPI/xpconnect side...

(note that I'm approximately the worst person to ask about how to efficiently pass a C++ callback to a JS XPIDL implementation, but an nsIRunnable would at least work, AIUI - there may be better things that you can use)

~ Gijs
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to