On 12/03/13 08:18, edw...@kenworthy.info wrote:
(def current-live-cells (atom starting-live-cells))
  (defn cells-changed
    ; called when current-live-cells changes
    [k r o n]
    (print "cells-changed called."))

  (add-watch current-live-cells :log cells-changed)


yes that is close...mind you, it's better if you give a meaningful name to your watch. I used :log because I'm logging boards...you should use :on-update or :repaint or something along these lines for your use-case....

On a side note, if you plan to bother with a gui, then you must have a look at seesaw...you won't have to use watchers there as you can specify what to 'listen' for and how to react on events with higher order functions...this is exactly the reason my board-history atom doesn't have a :on-update watch and only bothers with logging...I'm taking care of repainting logic elsewhere....

Jim



--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to