When I add a watch to a variable in clojure and rebind it, the watch is updated dynamically.
(def x "jlkfds")
x
In the above example x will always reflect its value.
However, when I try and do this using an atom, I have no luck. I have to execute the whole thing again to get the changes to reflect in either the instarepl or the watch.
(defonce y (atom 10))
@y *38*
(swap! y inc) *80*
In the above example I have executed the swap without executing the deref, and they have thus become out of sync.
What confuses me is that I saw a Javascript demo where someone (Chris) was able to watch the coordinates of a mouse pointer dynamically change. I really like the idea of having this functionality. Is there a way to do the same thing in Clojure?
Like this?
http://youtube.com/watch?v=d8-b6QEN-rk
Thank you