This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-29
Channels
- # announcements (4)
- # babashka (66)
- # beginners (7)
- # cljs-dev (6)
- # clojure (12)
- # clojure-europe (28)
- # clojure-nl (1)
- # clojure-norway (75)
- # clojure-uk (16)
- # clojuredesign-podcast (1)
- # clojurescript (16)
- # datascript (6)
- # deps-new (2)
- # dev-tooling (40)
- # exercism (1)
- # fulcro (92)
- # hyperfiddle (25)
- # lsp (19)
- # malli (1)
- # meander (2)
- # nrepl (9)
- # off-topic (5)
- # pathom (1)
- # practicalli (1)
- # re-frame (20)
- # reitit (14)
- # releases (1)
- # sci (86)
- # shadow-cljs (216)
- # sql (13)
- # testing (4)
- # tools-deps (4)
- # vscode (3)
no , looks optimization related which we mostly haven’t gotten to yet
not using https://github.com/hyperfiddle/electric/blob/master/src/hyperfiddle/history.cljc, but looking at it I'm wondering how you would restore scroll position on back/forward (life is very painful without this). You need some top-level way of knowing when everything has been rendered before you can set the scroll position. how do you do that when everything is rendered eagerly? is thunking ~@body always enough to perfectly defer all effects?
good q, we will need to think about this
possibly electric-dom will need to be changed, there have been some chats internally about doing batched dom updates which is related
differential electric is first
Hello! Is there any example in Electric we generally use JavaScript for learning. I.e. I picked a basic page (one input one button) on the internet and tried to write the same code in electric. But while same code working nicely in the HTML compiler My code in electric my javascript validation function doesn't work. What is wrong here? https://gist.github.com/Bariscanates404/4549b116fe44b3da1fd82315fedad4c9
why do you think it doesn't work? have you tried printing the value of username on click?
(def usernameInput (.getElementById js/document "username"))
executes on JS file load (when the page loads)
At the time it runs, the #username
HTML is not mounted yet
I giving an invalid number input i.e. "12" it must be a minimum of 3 characters. That doesn't show me an error as in HTML
well, geoffrey gave you the answer 😛 but generally you can narrow down what the problem must be by printing stuff out that you think should be run
Also, while Electric compiles down to JS, their evaluation model are different (imperative vs reactive). You cannot directly translate idiomatic JS into idiomatic Electric. Let me get back to you with an idiomatic Electric code snippet
electric creates the elements dynamically when the js is run, while the browser will read the html first and create those elements before the js is run
@U2DART3HA Thanks, I want to learn JavaScript usage in electric I think i will need it always 🙂
Notes:
• +
in clojure only does addition. Use str
to concatenate strings
• <
, >
, <=
, >=
can take more than two args. Useful to check ranges: “x is between 3 and 12 included” : (<= 3 x 12)
If you want to call addEventListener
manually, you can do so on dom/node
:
(dom/button ; in this block, the current DOM node is bound to `dom/node`
(dom/text "Click me")
(.addEventListener dom/node "click" handle-click))
(defn handle-click [^js event]
(js/alert "Button was clicked"))
I would consider doing all imperative js-style code in ordinary clojurescript until you have a reason not to. Just use defn
instead of e/defn
I guess you were already doing this, maybe this comment isn't helpful
How would you remove the reactivity from TwoClocks, such that the current time on server/client is displayed once immediately but then not updated? Or perhaps, add a button that turns the streaming updates on or off?