hyperfiddle

tobias 2025-03-15T06:27:20.488109Z

Tutorial 23 the countdown counter https://electric.hyperfiddle.net/tutorial/counter What is the purpose of the {} on L28?

(e/server ({} (swap! !n (e/Task (m/sleep 2000 inc))) ::ok))
I think the purpose of the {} is to force the swap! expression to complete before returning ::ok? I'm confused why replacing {} with do doesn't work (counter doesn't count down) as I expected that expressions inside a server block would run sequentially. If {} is being used to force execution order, then why not use case instead as I thought that was idiomatic?

Dustin Getz (Hyperfiddle) 2025-03-15T10:58:22.974799Z

you're right, case is idiomatic here, this is old

👍 1
Dustin Getz (Hyperfiddle) 2025-03-15T10:58:26.310039Z

ty for flagging

Dustin Getz (Hyperfiddle) 2025-03-15T11:00:12.323309Z

do here is electric-do, which is concurrent. you need to be in the body of a clojure.core/fn to get clojure-do

Dustin Getz (Hyperfiddle) 2025-03-15T11:01:28.587309Z

(do (dom/div (e/System-time-ms)) (dom/div 1)) is a good thought experiment for understanding why electric's do is concurrent

👍 2
Dustin Getz (Hyperfiddle) 2025-03-15T11:02:46.250759Z

also, (e/client (do (js/console.log (e/server (e/System-time-ms))) (js/console.log "boot"))) , the second console.log will (probably) run first due to latency

euccastro 2025-03-15T18:59:13.642209Z

Should I be concerned about "Reactor failure: missionary.Cancelled" errors in the JS console when I live-reload my Electric 3 app? These don't happen at app startup (e.g., if I start my REPL or reload the page), and they don't happen during app operation.

Dustin Getz (Hyperfiddle) 2025-03-16T12:47:20.478649Z

what browser

euccastro 2025-03-18T16:16:54.090289Z

Chrome on Ubuntu 24.04 > Version 134.0.6998.35 (Official Build) (64-bit)

euccastro 2025-03-15T19:05:23.785209Z

Expanded stacktrace: