Created
October 1, 2010 20:51
-
-
Save raek/606840 to your computer and use it in GitHub Desktop.
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 file-stored | |
"Creates an instance of ref-type with its value loaded from, and on changes | |
automatically stored in the file with the filename." | |
[ref-type filename] | |
(let [r (ref-type (read-string (slurp filename)))] | |
(add-watch r ::file-stored #(spit filename (pr-str %4))) | |
r)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment