This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-20
Channels
- # announcements (4)
- # beginners (5)
- # biff (1)
- # calva (2)
- # clj-kondo (32)
- # clojure (50)
- # clojure-czech (6)
- # clojure-europe (14)
- # clojure-nl (1)
- # clojure-norway (77)
- # clojure-uk (2)
- # core-logic (1)
- # cursive (6)
- # datahike (1)
- # datomic (15)
- # emacs (2)
- # events (1)
- # honeysql (1)
- # hyperfiddle (45)
- # introduce-yourself (2)
- # lsp (9)
- # other-lisps (10)
- # overtone (2)
- # polylith (5)
- # practicalli (1)
- # ring (2)
- # shadow-cljs (6)
When I hit the button to upvote items on my list of ranked items, i get triple, quadruple, quintuple "upvotes" on a single click -- i reckon this is because it's "streaming" the (inc upvotes)
command and that actually appllies more than one time. So it makes me wonder if i simply need to be more robust about ensuring every user can vote only once, or if there is some sort of fancy back-pressure swags i don't know how to use yet 😅
post your code, we will help
this is on the electric ui layer which event hauling idioms aren’t very natural yet, we’re working on a better idiom, for now we have to teach you the tricks
why does this need the IIFE? can the compiler not plumb reactivity inside ap
? I remember there was some problem with it, not sure if this was it
this is a missionary issue, ap
macroexpansion is not electric-friendly. The coroutine state is emitted as a mutable array and interpreted as electric code, the array does not depend on any reactive value so it's not reconstructed, the same state is incorrectly reused for all ap
runs.
also, I don't understand the question. Are you asking if this is still functional if it's orchestrating side effects?
just thinking about how un-clojurey it feels. you think it's better to emit a boolean than to not emit?
clojure doesn't solve IO. Missionary does, in a functional way. y/reductions
is a flow (a recipe to orchestrate IO) and flows compose correctly wrt IO
I think this has to be the idiomatic way in electric
(let [typed (Typing. (:text ctx))
idx (new (y/reductions (fn [acc _] (inc acc)) 0 typed))]
(when (odd? idx) (sound/play sound/DialogueBoop :rate 0.65 :volume 0.6)))
and now you can use idx
to know when it's done. not sure if there's a way to know when a flow has terminated generally> not sure if there's a way to know when a flow has terminated generally
You can run a clj fn when the flow is about to unmount with e/on-unmount
missionary flows can terminate, what is the requirement? discrete flows terminate a bit more natively than continuous flows though, bc signals broadly are defined for all time
well, that may not strictly be true because a child flow (continuous or discrete) can terminate and invoke cancellation effects as peter alluded, but then it can reboot. Cancellation on missionary propagates as an exception (causing siblings and parents to cancel per supervision)
i think continuous flows always cancel by exception? as opposed to discrete flows which can complete? possibly continuous flows can also complete its just weird and rare, more of an optimization to say “this signal is invariable and the current value is final”
observe
self-termination is not possible now, but may be in the future if needed. As a workaround you can push a sentinel value and add an eduction
stage with take-while
.
The notifier/terminator are not called because you're calling the flow with new
. This is electric specific, missionary is unaware of that
Passing notifier/terminator explicitly is expert mode, you should not do that unless you're learning internals
I figure electric supplies its own notifier/terminator to the flow with new
, but I was hoping it would compose with your own instead of just overriding them
new when called on a missionary flow doesn’t propagate parameters like that
what new does under the hood is bind the arguments in dynamic scope as %0 %1 etc and then joins the flow. an e/fn compiles down to a flow that optionally reads from %0 etc.
if you want to manually wire notify and terminate you should invoke the flow as a function per the missionary api
if you want to escape from electric context to intercept notify/terminate at some point in the electric program- i actually don’t know how to do that, the idea confuses me actually