On Friday, December 6, 2019 at 7:20:21 AM UTC+9, Geoff Lankow wrote:
> Hi all
>
> I'm redesigning a bunch of Thunderbird things to be asynchronous. I'd
> like to use Promises but a lot of the time I'll be far from a JS context
> so that doesn't really seem like an option. The best alternative I've
> come up with is to create some sort of listener object and pass it to
> the async function:
>
> interface nsIFooOperationListener : nsISupports {
> void onOperationComplete(
> in nsresult status,
> [optional] in string errorMessage
> );
> };
>
> ...
>
> void fooFunction(..., in nsIFooOperationListener listener);
>
> This works fine but I wonder if there's a better way, or if there's some
> established prior art I can use/borrow rather than find out the pitfalls
> myself.
>
> TIA,
> GL
I recently got a chance to play with MozPromise [0] in a pure C++ function to
access Windows API. It served my purpose well except that I had to use a bit
hacky way to pass `MozPromiseHolder` into a lambda expression.
[0]: https://phabricator.services.mozilla.com/D42484
_______________________________________________
dev-platform mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-platform