This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-18
Channels
- # adventofcode (12)
- # asami (2)
- # babashka (95)
- # beginners (17)
- # biff (5)
- # calva (1)
- # clojure (90)
- # clojure-europe (15)
- # clojure-nl (1)
- # clojure-norway (8)
- # clojure-uk (6)
- # clojuredesign-podcast (2)
- # clojurescript (34)
- # clr (1)
- # community-development (42)
- # cursive (11)
- # data-science (1)
- # datomic (13)
- # graalvm (5)
- # hoplon (2)
- # hyperfiddle (32)
- # off-topic (1)
- # pathom (6)
- # releases (1)
- # shadow-cljs (25)
- # squint (4)
- # xtdb (10)
I am having trouble updating the content of ui/input while I am focused on it. When the input becomes "\lorem", I want to replace the input with "Lorem ipsum dolor sit amet, consectetur adipiscing elit.".
(let [!txt (atom "")
txt (e/watch !txt)]
(div (text txt))
(ui/input
txt
(e/fn [v]
(if (= v "\\lorem")
(reset! !txt "Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
(reset! !txt v)))))
The change propagates only after I focus away from the input. How would I solve this issue?The UI controls do this on purpose, otherwise a concurrent update (e.g. from another user) could flow in as you're typing and make a mess
if the strategy bundled in ui controls doesn't work for you you can roll your own with dom/input
Differential Electric – very early sneak peak of streaming dom rendering over a large collection. Scenario is an industrial robot (shipyard crane) which we are observing live by tailing a log file. The robot runs at 20hz which the UI tails in realtime. The tracks are a plot of various record fields from the robot log, if you look closely you can see they are waves because the robot is moving back and forth. The tracks here are rendered in SVG and there are 1500 SVG elements being maintained (which is the soft limit according to google).
what is the mutable thing you have in mind to stream?
like if you're watching files instead of tailing logs, does differential have any impact on how you'd do it?
you’ll need to snapshot right? values over network
say you knew the memory layout of the robot, to read the state you map the memory into a struct, and then how does it go over to electric? have to write your own diffing protocol still (to do it efficiently) or does electric have an opinion on that
in this case a crane connector is translating the hardware structs and appending to a log; the structs arrive over a socket, the crane firmware is responsible for snapshotting the proper memory offset and writing to socket
so in your case you start with a discrete flow (socket), pre-diffed? what if you started with a continuous flow (file) too large to send over the network, does differential do/prefer anything special?
i'm guessing you'd still have to manually partition the flow into smaller flows for more efficient reactivity, differential doesn't help with that?
yes, you'll need to at least inject a diffing keyfn, i.e. imagine e/diff-by
(i.e. the first stage of e/for-by)
if you are ingesting a batch data source like a file or sql resultset you probably just want e/for-by
, which under Differential does the same thing as it did before just fancier internals
in this demo, halfway through when we speed up the playback rate, you can see the DOM stream in at the edges
One more, here we stream in 8k dom nodes basically instantly (note there are 3 tracks, the first one is faint)
this app runs on a LAN, but to your broader question, there aren’t any round trips so if network adds delay i don’t expect we would have a way to notice
I don’t know if every dom node corresponds to a network event or not, and whether they are logically a sequence, but if there are 8000 network events, the network latency kind of only applies to the first one. The first event to arrive will be delayed by 10/20/40/whatever ms, but after that they would arrive in roughly the same frequency as they were sent. Network latency is more of an “offset” than anything, when talking about bursts of events. Given a relatively stable internet connection. This changes if each requires an ack, which isn’t the case here.
@U06B8J0AJ good point!
which is being explored here https://github.com/hyperfiddle/electric/blob/master/src/hyperfiddle/incseq.cljc
this demo is implemented with incseq actually, incseq is the work horse of electric v3, the rest is mostly just syntax and upgrading the electric runtime to use incseq operators everywhere instead of vanilla missionary
Amazing