Try this:
(def a
(reify IDeref
(-deref [_] "Hello!")))
(.log js/console @a)
outputs "Hello!". You may want to use deftype:
(deftype LikeAtom []
IDeref
(-deref [_] "Hello!"))
(.log js/console @(LikeAtom.))
Question
Is there a way to make another container in cljs like it is in clojure by implementing IDeref?
(reify clojure.lang.IDeref
(deref [_] ...))
The compiler warns IDeref is not a protocol
Solution
Try this:
(def a
(reify IDeref
(-deref [_] "Hello!")))
(.log js/console @a)
outputs "Hello!". You may want to use deftype:
(deftype LikeAtom []
IDeref
(-deref [_] "Hello!"))
(.log js/console @(LikeAtom.))