Ok,here's a small example that propagates changes to a ref's vector to
a watcher:

;; define your model
(def model (ref ["abc" "def" "ghi"]))

;; define a watcher
(def model-watcher (agent nil))

;; connect your model to the watcher
(add-watcher model :send model-watcher (fn [state source] (println
(str @source))))

;; initiate a change to your model, which in this setup
;; will cause your watcher to execute the given action
;; and print the new state by dereferencing the model
(dosync (commute model conj "new value"))


--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to