Created
September 14, 2015 19:15
-
-
Save timmc/6df394983a24817ca3e3 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
(defonce timer (atom nil)) | |
(defn start-timer | |
[] | |
(swap! timer | |
(fn starter [old] | |
(when old (.cancel old)) | |
(let [period (* 300 1000)] | |
(doto (Timer. "updater" true) | |
(.schedule | |
(proxy [TimerTask] [] | |
(run [] (update!))) | |
0 | |
period)))))) | |
(defn stop-timer | |
[] | |
(swap! timer | |
(fn stopper [old] | |
(when old (.cancel old)) | |
nil))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment