   (:require-macros [cljs.core.async.macros :refer [go-loop go]])
   (:require [reagent.core        :refer [flush]]
             [re-frame.handlers   :refer [handle]]
-            [re-frame.utils      :refer [warn]]
+            [re-frame.utils      :refer [warn error]]
             [cljs.core.async     :refer [chan put! <! timeout]]))
 
 ;; -- The Event Conveyor Belt  --------------------------------------------------------------------

  "
  [event-v]
  (if (nil? event-v)
    (warn "re-frame: \"dispatch\" is ignoring a nil event.")     ;; nil would close the channel
    (put! event-chan event-v))
  nil)   ;; Ensure nil return. See https://github.com/Day8/re-frame/wiki/Beware-Returning-False


;;
(def ^:private event-chan (chan))    ;; TODO: set buffer size?

(defn purge-chan
  "read all pending events from the channel and drop them on the floor"
  []
  #_(loop []                          ;; TODO commented out until poll! is a part of the core.asyc API
    (when (go (poll! event-chan))     ;; progress: https://github.com/clojure/core.async/commit/d8047c0b0ec13788c1092f579f03733ee635c493
      (recur))))

;; -- router loop ---------------------------------------------------------------------------------
;;
