 
 (enable-console-print!)
 
+
+                                        ; HELPERS
+
 (defn pprint [s & args]
   (.log js/console (apply pr-str s args)))
+
+
+(defn target-val [e]
+  (.. e -target -value))
+
+                                        ; REPLIKATIV
 
 (def stream-eval-fns
   {'assoc (fn [a new]

    [:tr
     [:th "Description"]
     [:th "Date"]
     [:th "Value"]]
    (mapv
     (fn [{:keys [description value date] :as tx}]
       [:tr {:key (uuid tx)}
        [:td description]
        [:td (str (js/Date. date))]
        [:td value]])
     (sort-by :date > transactions))]])

(defui App
  Object
  (componentWillMount [this]
    (om/set-state! this {:input-description "" :input-value nil}))
  (render [this]
    (let [app-state (om/props this)
          {:keys [input-description input-value]} (om/get-state this)]
      (html
       [:div
        [:h3 "New Transaction"]
        (input-widget this "Description" :input-description :text)
        (input-widget this "Value" :input-value :number)
        [:button
         {:on-click (fn [e]
                      (do
                        (add-transaction!
                         app-state
                         {:description input-description
                          :date (.getTime (js/Date.))
                          :value input-value})
                        (om/update-state! this assoc :input-value nil)
                        (om/update-state! this assoc :input-description "")))}
         "Add"]
        (transactions-widget (vals (:transactions app-state)))]))))

(defn main [& args]
  (go-try S
          (def client-state (<? S (setup-replikativ)))
          (.error js/console "INITIATED")))

(om/add-root! reconciler App (.getElementById js/document "app"))

(comment


             :stream stream
             :peer local-peer})))


(declare client-state)


(defn add-transaction! [app-state tx]
  (s/assoc! (:stage client-state)
