core.async
0.3.465 was recently released with ASYNC-119 which makes the macros available in the cljs.core.async
namespace.
With ClojureScript clojure Namespace Aliasing, along with ClojureScript's ability to implicitly refer macros (see ClojureScript Macro Sugar), this means you can write code that works across Clojure and ClojureScript.
Furthermore, this has been ported and released in Andare 0.8.0, so the same code works in self-hosted ClojureScript!
Here is an example:
Fetch the Andare 0.8.0 JAR using boot
boot -d andare:0.8.0
Then make use of this new capability with either Planck or Lumo:
$ planck -qD andare:0.8.0
cljs.user=> (require '[clojure.core.async :refer [chan <! >! go]])
nil
cljs.user=> (def c (chan))
#'cljs.user/c
cljs.user=> (go (prn (<! c)))
#object[cljs.core.async.impl.channels.ManyToManyChannel]
cljs.user=> (go (>! c :hello))
#object[cljs.core.async.impl.channels.ManyToManyChannel]
:hello
Note that the require
form looks exactly like the one you would use in Clojure!