fix mutable cell for clj

This commit is contained in:
Nathan Marz 2015-06-24 18:27:26 -04:00
parent f3080d8e09
commit 6b0a907fff

View file

@ -315,10 +315,12 @@
;; cell implementation idea taken from prismatic schema library ;; cell implementation idea taken from prismatic schema library
(defprotocol PMutableCell (defprotocol PMutableCell
#?(:clj (get_cell [cell]))
(set_cell [cell x])) (set_cell [cell x]))
(deftype MutableCell [^:volatile-mutable q] (deftype MutableCell [^:volatile-mutable q]
PMutableCell PMutableCell
#?(:clj (get_cell [cell] q))
(set_cell [this x] (set! q x))) (set_cell [this x] (set! q x)))
(defn mutable-cell (defn mutable-cell
@ -329,7 +331,8 @@
(set_cell cell val)) (set_cell cell val))
(defn get-cell [cell] (defn get-cell [cell]
(field cell 'q)) #?(:clj (get_cell cell) :cljs (field cell 'q))
)
(defn update-cell! [cell afn] (defn update-cell! [cell afn]
(let [ret (afn (get-cell cell))] (let [ret (afn (get-cell cell))]