missionary

telekid 2025-10-16T15:51:30.823789Z

Very basic question: ๐Ÿงต

telekid 2025-10-16T15:53:02.003059Z

Is it possible to have "mounting" be printed once here?

(def v (atom 0))
(def >v (m/signal (m/watch v)))

(def a
  (m/cp
    (if (< (m/?< >v) 3)
      (println "mounting")
      (println "unmounting"))))

(def cancel ((m/reduce {} {} a) {} {}))

(swap! v inc) ;; prints mounting
(swap! v inc) ;; prints mounting
(swap! v inc) ;; prints mounting
(swap! v inc) ;; prints unmounting

telekid 2025-10-16T16:00:32.511609Z

I only want side effects to evaluate if my conditional expression changes from true to false or false to true

telekid 2025-10-16T16:09:29.326259Z

x/y: I want to mount or unmount flow B based upon the value of flow A, and I don't want to pay for repeated mounting of flow B if the result of the conditional test doesn't change.

telekid 2025-10-16T16:10:18.536219Z

I feel like this is probably obvious and I'm sure electric does it, I just can't seem to figure it out right now.

leonoel 2025-10-16T17:06:27.926259Z

the equality check is done by the switch, so you need an intermediate flow holding the conditional state

(def a
  (m/cp
    (if (m/?< (m/latest #(< % 3) >v))
      (println "mounting")
      (println "unmounting"))))

๐Ÿ™ 1
telekid 2025-10-16T17:17:11.711069Z

Ah, interesting. Thank you.