Last active
December 27, 2016 17:13
-
-
Save pbaille/1f06c116b33172937eb1cf033f44b03a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 set-timeout [f millis] | |
| (let [running (atom true)] | |
| (future | |
| (while @running | |
| (f) | |
| (Thread/sleep millis))) | |
| #(reset! running nil))) | |
| ;; start an interval, the stop function is returned and bound to stop-interval var | |
| (def stop-interval (set-interval #(println "yop") 1000)) | |
| ;; call it to stop it | |
| (stop-interval) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment