This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-14
Channels
- # ai (4)
- # babashka (4)
- # beginners (46)
- # biff (5)
- # calva (12)
- # clojure (6)
- # clojure-austin (13)
- # clojure-dev (27)
- # clojure-europe (62)
- # clojure-nl (1)
- # clojure-norway (17)
- # clojure-spec (2)
- # clojure-uk (12)
- # clojurescript (10)
- # cursive (3)
- # datahike (26)
- # datalevin (9)
- # datomic (7)
- # gratitude (4)
- # honeysql (9)
- # hyperfiddle (12)
- # instaparse (2)
- # lsp (65)
- # membrane (7)
- # missionary (2)
- # off-topic (8)
- # polylith (33)
- # portal (7)
- # quil (1)
- # re-frame (4)
- # reagent (18)
- # releases (3)
- # ring (3)
- # spacemacs (2)
- # specter (4)
Is differential electric already out there in some form to play with?
In (e/for-by f [x xs] (dom/li ,,,))
, I'm unsure of what f
does, and hence why e/for-by identity
leads to excessive recomputation. My guess is that for-by
gives each child (dom/li in this case) an invisible ID that is equal to f(x)
, so the dom node (or whatever) can be re-used when x changes, so f = identity
would entirely replace our dom/li when any aspect of x
changes, instead of re-using the existing node (/child). Am I close? Why doesn't e/for-by (constantly nil)
break?
yes, if you have used reagent or reactjs this is the “key”
as described here : https://electric.hyperfiddle.net/(electric-tutorial.demo-system-properties!%53ystem%50roperties)/
Yeah i'm afraid i've not used React. I did re-read the System Properties readme, but didn't quite follow enough.
One confusing thing in that readme is calling it a "reactive map operator" implied to me that it e/for-by f [x xs]
binds x like e/for-by identity [x (map f xs)]
, which I now know isn't true, but threw me.
Either way I get it now 🙂 Looks like a good default is to iterate over a vector of maps, and use e/for-by :db/id
to do so.
Thanks!
Oh! Final Q. In Electric, presumably this "key" is on the implicit do
that forms the for-by's body?
Yeah, the for-by body is wrapped into an e/fn, and the lifetime of that e/fn is controlled based on that key