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