                           .-value)
         new-item [(swap! id-atom inc) new-item-text]]
     (when new-item
+      ;; TODO: transact to server before stuff adding, no?
+      ;; id should be returned, not this swap! id-atom biz
+      ;; or use uuid gen on client, but not well-ordered then
+      (put! comm-alt {:tag :add-note! :value new-item})
+
       (om/transact! app :word-map #(merge-with union % (make-word-map new-item)))
       (om/transact! app :items #(conj % new-item))
-      ;; TODO: transact to server
       (secretary/dispatch! (str "#/notes/" (first new-item)))
       (set! (.-location js/window) (str "/#notes/" (first new-item))))))
 

                 (apply dom/div nil
                        (prepare-item item)))))))

(defn event-loop [app event-chan]
  (go
    (while true
      (let [[{:keys [tag value]} _] (alts! [comm-alt event-chan])]
        (. js/console (log "tag: " (pr-str tag)))
        (. js/console (log "value: " (pr-str value)))

        ;; when tag is add or search, do that
        ;; TODO: Generalize.
        (condp keyword-identical? tag
          ;; TODO: hide-all function
          :notes ;; more like view?
          (do (om/transact! app :hidden #(assoc % :add true))
              (om/transact! app :hidden #(assoc % :search true))
              (om/transact! app :hidden #(assoc % :view false))
              (om/transact! app :current-item (fn [_] (:id value))))
          :add
          (do (om/transact! app :hidden #(assoc % :view true))
              (om/transact! app :hidden #(assoc % :search true))
              (om/transact! app :hidden #(assoc % :add false)))
          :search
          (do (om/transact! app :hidden #(assoc % :view true))
              (om/transact! app :hidden #(assoc % :add true))
              (om/transact! app :hidden #(assoc % :search false)))
          )))))


(defn app-view [app owner]


;; Link format: [[foo|blitz]]

(defn debug [s x]
  (. js/console (log s (pr-str x))))

;; global extra channel for outer-Om comms
 (def comm-alt (chan (sliding-buffer 1)))

