photon nextjournal test (CLJ only)

{:deps {com.hyperfiddle/photon {:mvn/version "20220810-203215"}
        hyperfiddle/rcf                {:git/url "https://github.com/hyperfiddle/rcf"
                                        :git/sha "21f38ce1d15787b83696e6797be41f762619814f"}
        org.clojure/clojure            {:mvn/version "1.11.1"}
        ;; complient is used for autocompletion
        compliment/compliment {:mvn/version "0.3.9"}}}
Extensible Data Notation
(require
  '[hyperfiddle.rcf :as rcf :refer [tests ! % with]]
  '[hyperfiddle.photon :as p])
(hyperfiddle.rcf/enable!)
14.5s
(tests "hello world"
  (def dispose (p/run (rcf/! ::x)))
  % := ::x
  (dispose))
0.8s
(tests "react based on a ref"
  (def !x (atom 0))
  (def dispose (p/run (rcf/! (p/watch !x))))
  % := 0
  (swap! !x inc)
  % := 1
  (dispose))
0.7s
(tests "dataflow diamond"
  (def !x (atom 0))
  (def dispose
    (p/run
      (let [x (p/watch !x)
            a (inc x)
            b (inc x)]
        (! (+ a b)))))
  % := 2
  (swap! !x inc)
  % := 4
  (swap! !x inc)
  % := 6
  (dispose))
0.6s
(tests "reactive function call"
  (def !x (atom 1))
  (def !f (atom +))
  (with (p/run (let [f (p/watch !f)
                     x (p/watch !x)]
                 (! (f 0 x))))
    % := 1
    (swap! !x inc)
    % := 2
    (reset! !f -)
    % := -2))
0.7s
Runtimes (1)