js_of_ocaml icon indicating copy to clipboard operation
js_of_ocaml copied to clipboard

[FEATURE REQUEST] Integrate a Promise API

Open OlivierNicole opened this issue 6 months ago • 5 comments

The folks at Funkyworker have an API that nicely sidesteps the type unsafety of the JS Promise API: https://github.com/funkywork/nightmare/blob/main/lib/js/promise.mli (see also https://github.com/funkywork/nightmare/blob/main/lib/js/stubs/caml_promise_stubs.js)

Should we consider including it in Js_of_ocaml? I hear that they would be fine with this copyright-wise.

Having a Promise API would also unlock #596.

OlivierNicole avatar Jun 04 '25 12:06 OlivierNicole

PR would be welcome. It was attempted before but needed more work.

hhugo avatar Jun 04 '25 13:06 hhugo

What was the previous attempt?

OlivierNicole avatar Jun 04 '25 13:06 OlivierNicole

Having a Promise API would also unlock #596.

If that's your motivation note that this has been bound for ages in brr.

dbuenzli avatar Jun 04 '25 13:06 dbuenzli

Having a Promise API would also unlock #596.

If that's your motivation note that this has been bound for ages in brr.

Yes, and that's one of the inspirations for the stubs (Brr being mentioned). However, I think that, as a JSOO user, it's a feature I'd like to have directly, without having to depend on another library.

xvw avatar Jun 04 '25 13:06 xvw

We've been using https://github.com/mnxn/promise_jsoo for a few years now, and it's worked pretty well for us

TyOverby avatar Jun 04 '25 22:06 TyOverby