Skip to content

Instantly share code, notes, and snippets.

@noprompt
Last active December 25, 2015 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save noprompt/6909648 to your computer and use it in GitHub Desktop.
Save noprompt/6909648 to your computer and use it in GitHub Desktop.
(defn watch-file [file]
(let [mtime-chan (chan 1)
mtime (fs/mod-time file)]
(go (loop [old-mtime mtime new-mtime (inc mtime)]
(when (not= old-mtime new-mtime)
(put! mtime-chan new-mtime))
(recur new-mtime (fs/mod-time file))))
mtime-chan))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment