Fork me on GitHub
#hyperfiddle
<
2024-03-21
>
hkjels10:03:57

Has anyone created hooks for clj-kondo to prevent the warnings with e/server & e/client?

Dustin Getz12:03:13

i believe not, but as of the recent incremental compilation changes that released around christmas, this may now be feasible, namely because platform reader conditionals :cljs :clj now do the obvious expected thing in electric code blocks

hkjels13:03:49

I'm just getting to know electric, so I don't know what changes you are referring to I'm afraid. Maybe it's actually really easy.. Something along the lines of this maybe.

(defn cljs-wrap
  [{:keys [node]}]
  {:node :reader-conditional
   :forms [(assoc node :tag :cljs)]})

simonkatz13:03:12

Iā€™m doing this kind of thing:

(ns my-ns
  {:clj-kondo/config
   '{:linters {:unresolved-namespace {:exclude #?(:clj [cljs-only-ns-1
                                                        cljs-only-ns-2]
                                                  :cljs [clj-only-ns-1
                                                         clj-only-ns-2])}
               :unresolved-symbol {:exclude #?(:clj [cljs-only-symbol-1
                                                     cljs-only-symbol-2]
                                               :cljs [clj-only-symbol-1
                                                      clj-only-symbol-2])}}}}
  (:require
   ...))

šŸ‘ 3
simonkatz13:03:17

A bit clunky, perhaps, but at least it gets rid of the warnings.

simonkatz14:03:49

Any thoughts on how to easily implement (wrap?) a nice color picker?

simonkatz14:03:15

Thanks. I will take a look later.

simonkatz17:03:23

Great ā€” that helped.

Daniel Manila20:03:22

Is there a best practice for listening to a dom event in electric? I saw this https://github.com/hyperfiddle/electric/blob/master/src/hyperfiddle/electric_ui4.cljc#L105 but I'm not 100% clear on what it's doing (and I don't recall this being mentioned in the tutorial, but I could have missed it)

Vincent23:03:43

@U06KR2E1LHM Which events were you thinking? You can listen to events on each of the ui components with nested (dom/on ...) for electric fns and (dom/on! ) for pure clojurescript

(dom/on "keydown" ...)
Sometimes I attach javascript to the dom to trigger functions on page load etc. For ui components the dom/on[!]s are good