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!
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
(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)
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 🙂
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!
@nshepar you need to type in the tutorial examples, if you had done this you would understand how to do this
I have noted your implicit feedback that the tutorials in their current form did not get you there, we will improve over time
(e/for [item (e/diff-by identity collection)] (dom/div ( dom/text item)))
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
arg! I tried several e/for maneuvers..! ok thank you so much I was sure I was missing something