Fork me on GitHub
#hyperfiddle
<
2023-03-11
>
nivekuil00:03:36

now I can't unsee how inelegant react is. manipulating dom nodes is a side effect so why does useEffect even exist? so electric is like if every form was wrapped in useEffect with its dependencies auto-inferred

๐Ÿ‘ 2
Michael W00:03:40

Yes it's quite nice how little wiring you need to get a fully reactive state.

nivekuil01:03:28

anyone try to use electric with dependency injection yet? the ergonomics seem weird

Dustin Getz02:03:05

you mean integrating Electric with an external clojure DI framework? or are you looking for an Electric-native idiom for DI?

nivekuil02:03:56

external di framework

nivekuil02:03:07

I already made a decent feeling macro-based solution for clojure-only DI (e.g. injecting a database connection) but am curious if you guys have thought about it too

Dustin Getz02:03:58

why do you want to integrate an external DI framework? maybe what you want can be accomplished with electric itself

Dustin Getz02:03:42

electricโ€™s reactive dynamic bindings are basically equal in power to a DI framework

nivekuil02:03:44

there are non-electric components that use this database connection, say a kafka streams app

nivekuil02:03:20

or maybe I have a testing setup already built around this DI framework

Dustin Getz02:03:57

would love to take a look at your repo so we can understand the use case

nivekuil03:03:30

it's too much work for something I already have a reasonable solution for sorry, but I think it wouldn't be uncommon for someone to want to add electric to their existing luminus/ duct based web app

๐Ÿ‘ 4
Dustin Getz03:03:58

we will provide templates for that once we have understood the use case

nivekuil07:03:50

I think for dependency injection this has to work

(defn foo! [x]
  (e/defn Foo [y]
    (str x y)))
but e/defn does all its work at compile time, so this can never close over anything at runtime?

Dustin Getz11:03:38

i need to understand the use case, iโ€™m sure we can come up with a good pattern

Dustin Getz14:03:08

In clojure, what is the best REBL-like tool for connecting to an API and browsing it as data? Like, say, the github API, and hopefully using a high level object model, for example PyGithub via libpython-clj. Or casually traversing JSON might be enough

J15:03:42

Maybe portal

upvote 2
Michael W15:03:44

I use portal but never had to interact with it's api. Reveal is another to look at as well.

lread18:03:14

@U7RJTCH6J is doing some interesting experiments in this area too. There is a https://youtu.be/yPurwuTOHCE where he demos to @U6VPZS1EK.

๐Ÿ‘€ 2
phronmophobic19:03:30

The tool I demo works best if you already have the data locally. I use it frequently, but it's currently alpha. You might also interested in https://github.com/wilkerlucio/pathom-viz/. https://www.youtube.com/watch?v=YaHiff2vZ_o

๐Ÿ‘€ 2
phronmophobic19:03:06

I think #clerk would also work well as a means for exploring an API like github's.

phronmophobic19:03:14

For exploring github, you could probably do something cool with https://unpkg.com/browse/@octokit/[email protected]/generated/api.github.com.json

๐Ÿ‘€ 2
Dustin Getz22:03:41

thank you @U7RJTCH6J i need some time to digest

Michael W15:03:29

I'm having an issue with an svg, one of the properties for an svg animation is called xlink:href, but I cannot seem to make it work using svg/animate Here is a sample:

(svg/animate (dom/props {:attributeName "font-size"
                         :from "50"
                         :to "75"
                         :dur "1s"
                         :repeatcount "1"
                         :begin "click"
                         :xlink:href (str "#" tilename)}))
This obviously gives me an error in clojure, seeing as that is not a proper keyword. I looked at the macro that creates the animation document element but am not understanding how to translate that property name to a proper clojure keyword.

๐Ÿ‘€ 2
โœ… 2
Michael W15:03:05

Failed to execute 'setAttributeNS' on 'Element': '' is an invalid namespace for attributes.

 in ( hyperfiddle.electric-dom2/set-property! #object[SVGAnimateElement [object SVGAnimateElement]] xlink:href #tile0 )

๐Ÿ‘€ 2
Michael W15:03:37

I tried "xlink:href" and got that error, when I try :xlink/href that gets translated to just href on the properties, not "xlink:href" which would be the correct property.

๐Ÿ‘€ 2
Dustin Getz16:03:31

Ok, I will take a look with the team next week, are you blocked?

Michael W16:03:13

No it's just animations, I've got plenty of other stuff that is higher priority, I was just messing with animations for fun. Eventually I would like to get the animations working, but it's not affecting functionality of my app at all.

๐Ÿ‘ 2
Geoffrey Gaillard09:03:22

A fix is available on latest master. Note https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href, but might be needed for retrocompat.

๐Ÿ‘€ 2
Michael W18:03:33

Just a small thing, not sure it's even worth a fix. I noticed that if I have an atom that is a dictionary, and a watch setup on that atom, I cannot use the watch as a function, like I could with a "real" dictionary.

#?(:clj (defonce !state (atom {:test true})) :cljs nil)
(e/def state (e/server (e/watch !state)))

(e/client (dom/p (dom/text (str (state :test))))) => fails with an error about state not being a function
(e/client (dom/p (dom/text (str (:test state))))) => succeeds
(e/client (dom/p (dom/text (str (get state :test))))) => succeeds

๐Ÿ‘€ 2
Dustin Getz17:03:38

logged a bug, i think it's just an oversight