Skip to content

Instantly share code, notes, and snippets.

@clojens
Forked from swannodette/timeout.cljs
Last active August 29, 2015 14:07
Show Gist options
  • Save clojens/26544b371e6b7785dccd to your computer and use it in GitHub Desktop.
Save clojens/26544b371e6b7785dccd to your computer and use it in GitHub Desktop.
(ns async-test.timeout.core
(:require [cljs.core.async :refer [chan close!]])
(:require-macros
[cljs.core.async.macros :as m :refer [go]]))
(defn timeout [ms]
(let [c (chan)]
(js/setTimeout (fn [] (close! c)) ms)
c))
(go
(<! (timeout 1000))
(.log js/console "Hello")
(<! (timeout 1000))
(.log js/console "async")
(<! (timeout 1000))
(.log js/console "world!"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment