Adds a watcher to a cell to respond to changes of value. The is a
function of 4 values: a key, the cell, its old value, its new
value. This is implemented using Clojure's add-watch to the
underlying ref, and shared its sematics
(defn add-cell-watcher
"Adds a watcher to a cell to respond to changes of value. The is a
function of 4 values: a key, the cell, its old value, its new
value. This is implemented using Clojure's add-watch to the
underlying ref, and shared its sematics"
[cell key fun]
(let [val (:value cell)]
(add-watch val key (fn [key _ old-v new-v]
(fun key cell old-v new-v)))))
Comments top
No comments for add-cell-watcher. Log in to add a comment.