1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
(ns glimmer-cosmic.smoke
"Non-interactive: opens the window, re-renders from a timer on the worker
while libcosmic paints, prints the tree, and quits. Exercises the parts of
this backend that differ from glimmer-vidya — mounting before the loop, the
worker, schedule, commit, and quit from off the main thread."
(:require [glimmer.ratom :as r :refer [atom]]
[glimmer.core :as ui]
[glimmer-cosmic.core :as backend]))
(def ticks (atom 0))
(defn app []
[:page {:max-width 420}
[:card {}
[:title {:label "smoke"}]
[:label {:label (str "ticks: " @ticks)}]
[:progress {:value (/ (min @ticks 10) 10.0) :label "re-rendering from a timer"}]
[:checkbutton {:label "a checkbox" :active (odd? @ticks)}]
[:entry {:placeholder "an entry"}]]])
(defn -main [& _]
(backend/every! 100 #(swap! ticks inc))
(backend/after! 1500 #(do (backend/dump!) (backend/quit!)))
(ui/run app :title "glimmer-cosmic smoke" :width 480 :height 360)
(println "run returned; ticks =" @ticks))
|