If there was an atom:
(def a (atom {}))
with the following watches set
(add-watch a :watcher println)
(add-watch a :watcher2 println)
is there a function like this?
(get-watches a)
;; => [:watcher :watcher2]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
(atom {})creates an object of typeclojure.lang.Atomwhich extends abstract class clojure.lang.ARef which implements clojure.lang.IRef interface. IRef declares method getWatches that is implemented in ARef.Here’s the solution:
It is strange that
clojure.coredoesn’t haveget-watches. Mirroringadd-watchimplementation we get: