mirror of https://github.com/status-im/reagent.git
Add IWithMeta protocol to RAtom
This commit is contained in:
parent
95026c77fd
commit
5463bd8403
|
@ -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)
|
||||
|
||||
|
|
|
@ -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))))
|
Loading…
Reference in New Issue