photon reactive tree diffing

{:deps {compliment/compliment {:mvn/version "0.3.9"}
        org.clojure/clojure {:mvn/version "1.11.1"}
        com.hyperfiddle/photon {:mvn/version "20220827-153507"}
        com.hyperfiddle/rcf {:mvn/version "20220902-130636"}
        missionary/missionary {:mvn/version "b.27-SNAPSHOT"}}}
Extensible Data Notation
(require
  '[hyperfiddle.photon :as p]
  '[hyperfiddle.rcf :as rcf :refer [tests ! % with]]
  '[missionary.core :as m])
(hyperfiddle.rcf/enable!)
16.8s

(tests
  (def !order (atom {:account/email "alice@example.com" :order/items [{:item/sku 100 :order/count 2}]}))
  (def dispose
    (p/run
      (let [order (p/watch !order)
            {:keys [account/email
                    order/items]} order]
        (println "email: " (! email))
        (println "item count: " (! (count items)))
        (p/for-by :item/sku [{:keys [item/sku order/count]} items]
          (println "sku: " (! sku))
          (println "sku count: " (! count))))))
  "touch everything first time"
  % := "alice@example.com" ; email
  % := 1 ; item count
  % := 100 ; sku
  % := 2 ; sku count
  "point write"
  (swap! !order update-in [:order/items 0 :order/count] inc)
  % := 3 ; sku count
  "add another record, only touch what changed"
  (swap! !order update-in [:order/items] conj {:item/sku 101 :order/count 1})
  % := 2 ; item count
  % := 101 ; sku
  % := 1 ; sku count
  % := ::rcf/timeout ; assert no more came
  (dispose))
2.0s
Runtimes (1)