mirror of
https://github.com/status-im/reagent.git
synced 2025-01-27 04:05:50 +00:00
Merge pull request #314 from frerom/with-meta
Add IWithMeta protocol to RAtom
This commit is contained in:
commit
0b38b4467d
@ -146,6 +146,9 @@
|
|||||||
(-swap! [a f x y] (-reset! a (f state x y)))
|
(-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)))
|
(-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
|
IMeta
|
||||||
(-meta [_] meta)
|
(-meta [_] meta)
|
||||||
|
|
||||||
|
@ -461,3 +461,10 @@
|
|||||||
(r/flush)
|
(r/flush)
|
||||||
(dispose r1)
|
(dispose r1)
|
||||||
(is (= runs (running)))))
|
(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))))
|
Loading…
x
Reference in New Issue
Block a user