How can I make an IDerefable in clojurescript?
clojure, clojurescript
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.))
Problem
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