Add IWithMeta protocol to RAtom

This commit is contained in:
Fredrik Roman 2017-10-05 20:55:29 -04:00
parent 95026c77fd
commit 5463bd8403
2 changed files with 10 additions and 0 deletions

View File

@ -146,6 +146,9 @@
(-swap! [a f x y] (-reset! a (f state x y)))
(-swap! [a f x y more] (-reset! a (apply f state x y more)))
IWithMeta
(-with-meta [_ new-meta] (RAtom. state new-meta validator watches))
IMeta
(-meta [_] meta)

View File

@ -461,3 +461,10 @@
(r/flush)
(dispose r1)
(is (= runs (running)))))
(deftest ratom-with-meta
(let [value {:val 1}
meta-value {:meta-val 1}
state (with-meta (r/atom value) meta-value)]
(is (= (meta state) meta-value))
(is (= @state value))))