Skip to content

Instantly share code, notes, and snippets.

@mfikes
Last active May 23, 2016 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfikes/22f553d8c9186dcc613e1263ca9deeda to your computer and use it in GitHub Desktop.
Save mfikes/22f553d8c9186dcc613e1263ca9deeda to your computer and use it in GitHub Desktop.
core.async in self-hosted / bootstrapped ClojureScript

It is possible to rearrange the core.async code so that it is compatible with self-hosted / bootstrapped ClojureScript.

Some changes needed to get things to work are in this fork: https://github.com/mfikes/andare

Below is a demo of some fundamental concepts working.

Note: The fork has been published to Clojars as "Andare," and a Quick Start on how to use it with Planck is at https://gist.github.com/mfikes/30098db2366dd25b91b2c4de0a685888

Clone the fork and then start up Planck, pointing it at the core.async source.

$ planck -qdc core.async/src/main/clojure
cljs.user=> (require-macros '[cljs.core.async.macros :refer [go]])
nil
cljs.user=> (require '[cljs.core.async :refer [chan <! >! put! timeout]])
nil
cljs.user=> (def c (chan))
#'cljs.user/c
cljs.user=> (go (while true (let [x (<! c)] (println "c:" x))))
#object[cljs.core.async.impl.channels.ManyToManyChannel]
cljs.user=> (put! c :hello-from-self-host)
truec: :hello-from-self-host

cljs.user=> (go (while true (<! (timeout 2500)) (>! c 1)))
#object[cljs.core.async.impl.channels.ManyToManyChannel]
cljs.user=> c: 1
c: 1
c: 1
c: 1
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment