Created
December 14, 2018 11:26
-
-
Save divs1210/b00cee39fb1f5f0ab210b7ec6d193902 to your computer and use it in GitHub Desktop.
Lightweight logging of db state changes for reagent/re-frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn watch-db [] | |
(add-watch re-frame.db/app-db :watcher | |
(fn [_ _ old-state new-state] | |
(let [[removed added] (clojure.data/diff old-state new-state)] | |
(when (or removed added) | |
(println "=====\nRemoved:") | |
(cljs.pprint/pprint removed) | |
(println "Added:") | |
(cljs.pprint/pprint added)))))) | |
(defn unwatch-db [] | |
(remove-watch re-frame.db/app-db :watcher)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment