 ;; ==========================
 ;;
 
+(def sync-ch (chan))
+
 (defn editable-input
   [state owner {:keys [key type label placeholder]}]
   (reify

               (om/build editable-input
                         (-> app :server-state :input1)
                         {:opts {:key :value
                                 :type "text"
                                 :label "text2"
                                 :placeholder "placeholder2"}})
               (when err-msg
                 (dom/div nil err-msg))))))


                               :placeholder placeholder
                               :onChange (fn [e])
                               :onBlur (fn [e]
                                         (let [newval (.. e -target -value)]
                                           (put! sync-ch (str "a message: " newval))
                                           (om/transact! state key (fn [] newval))))})))))

(defn synced-view
  [state owner {:keys [view channel] :as opts}]
  (reify
    om/IWillMount
    (will-mount [_]
      (go-loop [msg (<! channel)]
        (println "got sync message:")
        (println owner)
        (println state)
        (println msg)
        (println "===")
        (recur (<! channel))))
    om/IRender
    (render [_]
      (om/build view state {:opts opts}))))

;;
;; ==========================
