       c ([x] x)
       (async/timeout msec) (ex-info (str "Timeout " msec "ms") {::timeout msec}))))
 
+(defn delay [ms]
+  (let [c (chan)]
+    (js/setTimeout #(close! c) ms)
+    c))
+
 (defn wait-for
   ([f] (wait-for f 100))
   ([f interval]

(ns common.async
  (:refer-clojure :exclude [map mapcat filter remove distinct concat take-while drop-while complement keep reduce])
  (:require-macros [cljs.core.async.macros :refer [go alt! go-loop]]
                   [common.async :refer [dochan go-catch <? <!expand]])
  (:require [goog.net.Jsonp]

       (if (f)
         (async/close! c)
         (do
           (<! (delay interval))
           (recur))))
     c)))
