This file sets enables a watch-style auto-compilation on cljs file changes.
watch.sh
Because you need java to actually run the watch.clj file, and because i always forget the exact java command, i make a bash script to make it easy.
So as long as you have a .cljs file in /src, we can now run . watch.sh and as we do our dev, it gets compiled and placed in /assets/js. So easy.
A Real Example
Ok, so here we go. I want to see how quickly/easily i can get google visualization library to work with cljs. Let’s start out with a super simple html page for our test:
index.html
Ok so we got some google viz loading in here, and then finally our cljs.js file as well.
src/main.cljs
In this file we’re going to take an array/vector of data and “paint” it on a timeline.
A few notes on this:
Note that in order to convert clojure maps to javascript object literals we use the #js reader macro. This does not work on nested objects however…
For nested objects (ie, my-data) when we want to convert from clojure to javascript objects we use the clj->js adapter function.
doto is just so useful when dealing with object oriented libs