       (js/Raven.captureMessage log-msg)
       (log/error log-msg))))
 
-;; TODO: add pause for rendering after fixed interval
 (defn handle-event* [{:as router-ctx :keys [conn ev-chan notify-chan]} msg]
   (let [ev-ctx (assoc router-ctx :db @conn)
         {:as ret :keys [tx]} (handle-event ev-ctx msg)]

      (players/notify notify-chan notify-msg))))

(defn start [{:as router-ctx :keys [ev-chan]}]
  (go-loop [msg (<! ev-chan)]
    (when msg
      (try
        (log/debugf "Handling event: %s" (pr-str msg))
        ;; TODO: validate event
        ;; TODO: validate handler return value
        (handle-event* router-ctx msg)
        (catch :default ex
          (js/Raven.captureException ex)
          (log/errorf ex "Error handling event: %s" (pr-str msg))))
      (recur (<! ev-chan)))))

(ns zetawar.router
  (:require
   [cljs.core.async :refer [chan close! put! sliding-buffer]]
   [cljsjs.raven]
   [datascript.core :as d]
   [reagent.core :as r]
   [taoensso.timbre :as log]
   [zetawar.players :as players])
  (:require-macros
