Fork me on GitHub
#hyperfiddle
<
2023-10-08
>
nivekuil03:10:52

typing animation; need differential electric to do this better?

(e/for [c (->> (y/ap (let [c (y/?> (y/seed elt))]
                       (y/? (y/sleep 50 c))))
               (y/reductions (fn [acc n] (conj acc n)) [])
               new)]
   (ed/text c))

Dustin Getz13:10:15

not immediately.l clear what this is can you post more context pls

Dustin Getz21:10:41

also i don’t think m/ap and the other missionary coroutine DSLs are electric compatible yet due to use of mutable arrays in the cloroutine macroexpansion, you’ll need to wrap them in clojure. i believe the symptom of this is they will crash so perhaps you are getting lucky here

nivekuil21:10:01

good to know. this is just for typing out a string char by char. the only small problem I see with this is that you have to conj into this vector to return from the flow, which you just iterate over for effects anyway with e/for

Dustin Getz21:10:00

yes that seems right

xificurC06:10:34

typing animation; need differential electric to do this better?if the characters are coming in one by one, in the differential world you could send diffs. But for a small string/collection you shouldn't notice performance issues or delay today. If you already have the characters then animating them sounds like a job for CSS

nivekuil07:10:32

would if I could, but I need more than dom. I'm aware how much slower it is to do it through missionary, my finger got tired scrolling the flamegraph

Dustin Getz10:10:19

oh was this a perf question? your typing indicator snippet is not fast enough in some way? please provide context

nivekuil10:10:06

no, this is just a best practices question with no practical perf requirement. I do have perf problems with electric (~500ms to render a component) though I haven't done anything to optimize it aside from glancing at the hilarious flamegraph

nivekuil10:10:40

it's not unexpected that stuff feels jankier than react since it does all the work eagerly, no scheduler or anything

xificurC10:10:16

there's most likely low hanging fruit inside electric to improve performance, since we haven't done much profiling and optimizations, only the ones we needed to unblock us or client projects

nivekuil10:10:41

yeah I don't see it as a priority, but I was expecting to see layout thrashing and I think it was more gc pressure

Hendrik14:10:38

I have a macro, that returns a e/defn , but I can’t get it to work. Here is my minimum failing example:

; in file foo
(defmacro defn2 [label args & body]
  `(e/defn ~label ~args ~@body))
; in file bar
(defn2 Foo []
  (dom/div (dom/text "meh")))
(e/defn Root []
  (new Foo))
This fails with
; Encountered error when macroexpanding hyperfiddle.electric/boot.
; Unable to resolve symbol: Foo
; {:file xxxx, :line 41, :column 4, :end-line 41, :end-column 13, :in [(new Foo)]}
; ExceptionInfo: Unable to resolve symbol: Foo
Am I missing something here?

Dustin Getz16:10:18

did you remember to :require-macros in cljs

Hendrik16:10:44

🙈 that did the trick. I thought I tested that, but probably I had some stale state in my repl. Thanks for the hint. You saved my nerves :D

🙂 1