Skip to content

Instantly share code, notes, and snippets.

@timmc
Created September 14, 2015 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timmc/6df394983a24817ca3e3 to your computer and use it in GitHub Desktop.
Save timmc/6df394983a24817ca3e3 to your computer and use it in GitHub Desktop.
(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