simplify. remove tick

This commit is contained in:
2026-01-22 22:22:19 -05:00
parent 8cb4c82daa
commit 8c7cb24171
9 changed files with 133 additions and 88 deletions
+11 -12
View File
@@ -9,7 +9,6 @@
;; === Command Types ===
;; nil - no-op
;; [:quit] - exit program
;; [:tick ms] - send :tick message after ms
;; [:batch cmd1 cmd2 ...] - run commands in parallel
;; [:seq cmd1 cmd2 ...] - run commands sequentially
;; (fn [] msg) - arbitrary async function returning message
@@ -17,10 +16,17 @@
;; === Built-in Commands ===
(def quit [:quit])
(defn tick
"Send a :tick message after ms milliseconds."
[ms]
[:tick ms])
(defn after
"Returns a command that sends msg after ms milliseconds.
Use this for timers, animations, or delayed actions.
Example:
(after 1000 [:timer-tick])
(after 80 [:spinner-frame {:id 1}])"
[ms msg]
(fn []
(Thread/sleep ms)
msg))
(defn batch
"Run multiple commands in parallel."
@@ -47,13 +53,6 @@
(= cmd [:quit])
(put! msg-chan [:quit])
;; Tick command
(and (vector? cmd) (= (first cmd) :tick))
(let [ms (second cmd)]
(go
(<! (timeout ms))
(>! msg-chan [:tick (System/currentTimeMillis)])))
;; Batch - run all in parallel
(and (vector? cmd) (= (first cmd) :batch))
(doseq [c (rest cmd)]