(CLJS) js/Promise interop via core.async.interop


This issue follows up on a discussion about core.async.interop 31/10/2019 on Clojurians #clojurescript channel where it was noted that questions about promises were a recurring topic.

David Nolen provided a macro and remarked that it could be a candidate for the core.async.interop namespace along with a post on the topic.

I put up https://github.com/filipesilva/async-interop with the macro, some tests, and what I imagine could be a guide in https://clojurescript.org/guides/ (except for this "Notes" section).

The guide page can be found at , and attached is a patch for core.async.





Alex Miller
March 31, 2020, 7:54 PM

Released in core.async 1.1.582

Filipe Silva
November 4, 2019, 10:17 PM

Here’s an update patch so that the throw logic is inside a function:

Right now the macro looks like this:

So the public names are throw-err, p->c , and <p!. I imagine the public names are chosen carefully so that the API can remain stable, so please let me know if you’d like them changed (e.g. to Thomas Heller’s unwrap-promise, wrap-promise, and await).

Filipe Silva
November 4, 2019, 9:47 PM

I don’t have an opinion about the name myself, happy to go with whatever people thing is best.

Regarding the macro, I think I’ll ping you on slack for clarification.

Filipe Silva
November 4, 2019, 9:46 PM

I don’t follow, isn’t the third argument to ex-info the cause? I’m sending err as the third argument and testing that the same instance is there in this test:


Your pinned fields
Click on the next to a field label to start pinning.


Filipe Silva


Filipe Silva