Merge pull request #314 from frerom/with-meta

Add IWithMeta protocol to RAtom
This commit is contained in:
Juho Teperi 2017-10-20 11:07:05 +03:00 committed by GitHub
commit 0b38b4467d
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))))