Skip to content

Instantly share code, notes, and snippets.

@metametadata
Created June 18, 2015 11:48
Show Gist options
  • Save metametadata/7ea557f8a2f1bdddd574 to your computer and use it in GitHub Desktop.
Save metametadata/7ea557f8a2f1bdddd574 to your computer and use it in GitHub Desktop.
sleep in clojurescript
(defn sleep [msec]
(let [deadline (+ msec (.getTime (js/Date.)))]
(while (> deadline (.getTime (js/Date.))))))
@niicM
Copy link

niicM commented Feb 16, 2017

Running this made my project freeze. (js/setTimeout (fn []) timeout) was what I ended using.

@metametadata
Copy link
Author

@niicM yes, this snippet shouldn't be used in 99,9% of cases. It just hangs the CPU :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment