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

                               :placeholder placeholder
                               :onChange (fn [e])
                               :onBlur (fn [e]
                                         (om/transact! state key
                                                       #(.. e -target -value)))})))))

(defn server-synced-view
  [state owner]
  (reify
    om/IRender
    (render [_]
      (dom/input #js {:type "text" :value (:value state)
                      :onChange (fn [e])
                      :onBlur (fn [e]
                                (om/transact! state :value
                                              (fn [_]
                                                (.. e -target -value))))}))))

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

               (om/build editable-input
                         (-> app :server-state :input1)
                         {:opts {:key :value
                                 :type "checkbox"
                                 :label "check1"}})
               (om/build editable-input
                         (-> app :server-state :input1)
                         {:opts {:key :value
                                 :type "text"
                                 :label "text2"
                                 :placeholder "placeholder2"}})
               (om/build synced-view
                         (-> app :server-state :input1)
                         {:opts {:view editable-input
                                 :channel sync-ch
                                 :key :value
                                 :type "text"
                                 :label "synced1"
                                 :placeholder "placeholder3"}})
               (when err-msg
                 (dom/div nil err-msg))))))

