 (defmulti read (fn [& args] (namespace (apply om/dispatch args))))
 (defn direct-read [state k] {:value (get @state k nil)})
 (defmethod read nil [{:keys [state] :as env} k {:keys [idx file offset limit]}]
-  (case k
-    ;;    :visible-packets
-
-    ;;     :packets
-    ;;     (let [packets (or (get @state :packets []) [])
-    ;;           last-idx (max 0 (dec (count packets)))
-    ;;           start (min offset last-idx)
-    ;;           end (min (+ limit offset) last-idx)]
-    ;;       {:value (subvec packets start end)})
-    ;;     :packet (when idx {:value (get (get @state :packets []) idx)})
-    ;;     :packets-count {:value (count (get @state :packets))}
-
-    (direct-read state k)))
+  (case k (direct-read state k)))
 
 (defn read-expr [s]
   (if-let [src (try (reader/read-string s)

             (when (not= old-file file) {:file ast})))))

(defn mutate [{:keys [state] :as env} key {:keys [value]}]
  ;;  (println "mutaatin" key (type key) value (-> key name keyword))
  (cond
    #{`selected-idx `offset}
    (let [state-key (-> key name keyword)]
      {:value {:keys [state-key]}
       :action #(swap! state assoc state-key value)})

    ;;    #{`packets}
    ;;    (let [state-key (-> key name keyword)]
    ;;      {:value {:keys [state-key]}
    ;;       :action #(swap! state assoc state-key value)})

    true {:value (swap! state assoc key value)}))

(defn send-to-chan [c]

(om/add-root! reconciler RootComponent (gdom/getElement "app"))

(defn on-figwheel-reload [& args] (println "Figwheel reloaded!" args))
