hyperfiddle

Noah Shepard 2025-07-02T04:46:50.231879Z

May I ask a "how do I X" question? I dont see it in the docs - I have a vector of strings, I'd like to (dom/td (dom/text item)) each item in that vector. (mapv (dom/text) collection) seems to not work - macro expansion fails on the line where I try to map an electric dom function over the collection. Thanks in advance!

Dustin Getz (Hyperfiddle) 2025-07-02T10:06:59.616429Z

clojure collections are not reactive so in Electric we mostly can't use them. Same in other UI libraries - in React, every time you use a collection you incur a O(n) traversal in userland and then another in the reconciler to unpack it again

Dustin Getz (Hyperfiddle) 2025-07-02T10:08:19.382809Z

(I think this is a major impedance mismatch between current generation functional programming and user interfaces, the whole request/response "pure function" mindset is a terrible fit for user interfaces)

💯 2
Noah Shepard 2025-07-02T21:51:59.072349Z

I've always enjoyed render-my-ui as a pure fn of state (elm architecture) as a model, but then I tend to be a front-end SPA style developer - Ive been able to get away with keeping server interactions way at the edges of my software. Now that I'm working in a place with many different independent data services all running around, to say nothing of our pile of bespoke, verbose, bugggggy crud-apps for each one... I am very sold on the premise of Electric 🙂

Noah Shepard 2025-07-02T22:01:27.056259Z

I think the problem for me (super new to clojure and electric, I know its not for beginners but here I am anyway) is understanding when I need reactivity, or where to expect the electric stuff to stop playing nice with regular clojure. for me, it was a surprise to not be able to call an electric function within e/Offload, and I struggled to find the electric-wording for a basic idea (mapv (e/text) collection) . In places where I need iteration, but I (the programmer) know its bounded, would it be valuable (is it even possible?) for electric to relax on reactivity (and sacrifice perf/scalability) in the name of compatibility / composability? Sorry to ramble, these are just my current thoughts on trying to learn this - I'm betting you all have thought much harder about all this already!

Dustin Getz (Hyperfiddle) 2025-07-03T10:24:11.983869Z

@nshepar you need to type in the tutorial examples, if you had done this you would understand how to do this

Dustin Getz (Hyperfiddle) 2025-07-03T10:24:46.737899Z

I have noted your implicit feedback that the tutorials in their current form did not get you there, we will improve over time

Hendrik 2025-07-02T04:50:45.321999Z

(e/for [item (e/diff-by identity collection)] (dom/div ( dom/text item)))

Hendrik 2025-07-02T04:53:30.770349Z

e/diff-by converts a collection into an incremental collection. That means e/diff-by returns the difference between 2 collections. e/for materializes the diffs and maintains a branch for each entry in the materialized collection

Noah Shepard 2025-07-02T04:53:33.727079Z

arg! I tried several e/for maneuvers..! ok thank you so much I was sure I was missing something