Welcome! Please see the About page for a little more info on how this works.

0 votes
ago in ClojureScript by

In ClojureScript (as of 1.12.145) one can declare a function (defn, fn) to be async by adding the metadata ^:async. However, the same is not applicable to protocol functions and multi-methods. Since async is an invocation semantic, should it be carried over to protocol functions and multimethods? (If yes, should it apply to the protocol definition in defprotocol or to the protocol implementation in reify?)

If async is not to be allowed in protocol functions and multimethods, then the documentation should clearly mention the omissions, alternatives and workaround.

2 Answers

+1 vote
ago by

Thanks for reaching out. I don't think adding async support to protocols / multi methods adds significant value. We can update the documentation to make it clear this is very much a light-weight interop feature, not a general language direction.

+1 vote
ago by

As this isn't going to be supported (yet) a workaround that you can use everywhere is:

((^:async fn [] ...your method body here...))
...