Skip to content

Instantly share code, notes, and snippets.

@yedi
Created September 11, 2014 06:28
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 yedi/1abcdf0d8675fd532eca to your computer and use it in GitHub Desktop.
Save yedi/1abcdf0d8675fd532eca to your computer and use it in GitHub Desktop.
async timeout lag
;; copy and paste this code into cljsfiddle.com (or your local cljs environment)
(ns cljsfiddle
(:require [cljs.core.async :as async
:refer [<! >! put! chan timeout close!]])
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))
(defn print-time! [s]
(print (str s ": " (.getTime (js/Date.)))))
(let [ch (chan)]
(go (while true
(<! (timeout 1000))
(>! ch "")
(print-time! "sent")))
(go (while true
(<! ch)
(print-time! "recv"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment