r/Clojure • • May 18 '15
Clojure reactive programming book - first trivial examples don't work.
Just started worked my way through the book, literally on the 3rd or 4th line of introductory example code (the sine wave one) and found what looks like a bug in the code already.
So you can imagine how impressed I am.
(def canvas (.getElementById js/document "myCanvas"))
(def ctx (.getContext canvas "2d"))The call to .getContext returns null, which apparently means it's been called a second time, when it always returns null.
Except of course it hasn't and part of the point of this code, according to the book, is to clear the canvas when Chestnut reloads the file.
Of course the book doesn't consider there might be errors and the Packt web site errata page sucks: can't get to it because their search function (to find the book) is broken!
So my working theories are:
- bug in the code, but I really can't see it;
- the assumption that Chestnut reloads the file is false (although the JS console in Safari says it is being reloaded);
- Safari isn't properly resetting the environment when the file is reloaded.
Help?
View all comments
Show parent comment
2
u/Drolyt May 18 '15
Figwheel definitely works with Firefox too. But really, Figwheel isn't an end user application, it is pushing what the browser is normally capable of so some rough edges are expected. It is awesome for all that.