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?you're right, case is idiomatic here, this is old
ty for flagging
do here is electric-do, which is concurrent. you need to be in the body of a clojure.core/fn to get clojure-do
(do (dom/div (e/System-time-ms)) (dom/div 1)) is a good thought experiment for understanding why electric's do is concurrent
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
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.
what browser
Chrome on Ubuntu 24.04 > Version 134.0.6998.35 (Official Build) (64-bit)
Expanded stacktrace: