   (:import goog.History))
 
 ;; Link format: [[foo|blitz]]
+
+;; global extra channel for outer-Om comms
+ (def comm-alt (chan (sliding-buffer 1)))
 
 (secretary/set-config! :prefix "#")
 

(ns unfolds.core
  (:require-macros [cljs.core.async.macros :refer [go]]
                   [secretary.core :refer [defroute]])
  (:require [clojure.set :refer [union]]
            [clojure.string :refer [split]]
            [goog.events :as events]
            [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]
            [cljs.core.async :refer [put! chan <!]]

      (dom/div #js {:style (hidden (-> app :hidden :item))}
               (str (-> app :item))))))

(defn event-loop [app event-chan]
  (go
    (while true
      (let [foo (alts! [comm-alt event-chan])]
      (. js/console (log "chan: ") (pr-str foo))))))

(defn app-view [app owner]
  (reify
    om/IInitState
    (init-state [_]
      {:chans {:event-chan (chan (sliding-buffer 1))}})
    om/IWillMount
    (will-mount [_]
      (let [event-chan (om/get-state owner [:chans :event-chan])]
        (event-loop app event-chan)))
    om/IRenderState
    (render-state [this {:keys [chan] :as state}] ;; syntax?
      (dom/div nil
               #_(dom/h1 nil (str (:text app) " " (:count state)))
               (dom/a #js {:href "#/notes/1"} "1")
               (dom/a #js {:href "#/notes/2"} "2")
               (dom/p nil
                      (str "Search: ")
                      (dom/input #js {:value (:search state)
                                      :type "text"
                                      :ref "search"
                                      :onChange
                                      #(handle-search-change % owner state)})
                      (dom/button #js {:onClick #(search app owner)} "Search"))
               (dom/textarea #js
                              {:value (:text state)
