I would like to follow the changes in different parts of the Clojure hash map (access via STM ref), which forms a fairly large tree, and with changes in those parts I would like to call some registered listeners. How to do this in Clojure, since I understand that add-watch only works with the whole link?
I will also observe the whole tree and check the subsets with the entrance. Can you quickly check if a subtree has been changed using an identical one? test against the previous state. Sort of
(defn change-tester [tree path] (let [orig (get-in tree path)] (fn [tree] (not (identical? (get-in tree path) orig)))))
I don’t use observers often, so I don’t know the syntax, but you can somehow attach this function, I'm sure.
Clojure , , .
:
Clojure , , , . "" , , . ( , , .)
, , , - , , , HashMap, Java, Clojure Map.
Java HashMap, "put" "putAll", , . HashMap HashMap, , sub HashMap , .
"WatchfulHashMap". HashMap, :
(def m (ref (WatchfulHashMap.)))
, .
Source: https://habr.com/ru/post/1783119/More articles:When should I not set the @OutputCache Shared Attribute attribute in Webforms? - webformsMutex DLL - example - c ++Where is a good source of documentation for the Pylons web infrastructure? - pythonDLL Thread Security - c ++Quicksort to sort an array of objects by a specific C ++ member - c ++XMLParseException when searching with tmdb C # api - c #UDP packet exceeding 1500 bytes - linuxPostgreSQL: синтаксис левого внешнего соединения - outer-joinORM, DataBinding for DataGridView: insert / delete new rows not stored in the database - c #What is the easiest way to make configuration files in Java? - javaAll Articles