diff options
| author | Jake Zerrer <him@jakezerrer.com> | 2025-11-21 11:51:47 -0500 |
|---|---|---|
| committer | Jake Zerrer <him@jakezerrer.com> | 2025-11-21 12:00:35 -0500 |
| commit | 52a68dc56db4dbf6c1295d3122dcfce32c1b55e5 (patch) | |
| tree | 59cb07c869c737fc545399b7008d5fbff0407d71 | |
| parent | 715f427e11a6b33111cbcd06bbb816f042455035 (diff) | |
POC of reactive timeline
| -rw-r--r-- | src/unheard/theory.clj | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/unheard/theory.clj b/src/unheard/theory.clj index e9e4ad5..6ceff3e 100644 --- a/src/unheard/theory.clj +++ b/src/unheard/theory.clj @@ -7,8 +7,12 @@ [>clock start duration >value] (time-object start duration - (m/cp (let [[c v] (m/?< (m/latest vector >clock >value))] - (if (<= start c (dec (+ start duration))) #{v} #{}))))) + [(gensym) + (m/cp (let [[c v] (m/?< (m/latest vector >clock >value))] + (if (<= start c (dec (+ start duration))) #{v} #{})))])) + +;; Reducing function that returns diffs :add v :remove v +;; Reducing function that unfolds to values (comment (require '[unheard.time-object :refer [lift phrase timeline point-query]]) @@ -20,6 +24,15 @@ (def song (phrase (lift n))) (def t (timeline (song 0))) (def r (point-query t >c)) + (def r + (m/ap (try (m/?< + ;; TODO: Simplify + (apply m/latest + vector + (point-query t >c) + (vals (m/?< (m/eduction (map #(into {} %)) + (point-query t >c)))))) + (catch missionary.Cancelled _ (m/amb))))) (def cancel ((m/reduce prn nil r) prn prn)) (cancel) (swap! c dec) |
