              :stream stream
              :peer local-peer})))
 
+(declare client-state)
+
+(defn add-transaction! [app-state tx]
+  (s/assoc! (:stage client-state)
+            [user ormap-id]
+            (uuid tx)
+            [['assoc tx]]))
 
 (defn target-val [e]
   (.. e -target -value))

(ns takarabako.core
  (:require [konserve.memory :refer [new-mem-store]]
            [replikativ.peer :refer [client-peer]]
            [replikativ.stage :refer [create-stage! connect!
                                      subscribe-crdts!]]

            [hasch.core :refer [uuid]]
            [replikativ.crdt.ormap.realize :refer [stream-into-identity!]]
            [replikativ.crdt.ormap.stage :as s]


(enable-console-print!)

(defn pprint [s & args]
  (.log js/console (apply pr-str s args)))

(def stream-eval-fns
  {'assoc (fn [a new]
            (swap! a assoc-in [:transactions (uuid new)] new)
            a)
   'dissoc (fn [a new]
             (swap! a update-in [:transactions] (fn [txs] (dissoc txs (uuid new))))
             a)})


