This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
Did anyone here watch the London Clojurians talk about HumbleUI?? The approach is so similar to reagent I think it will feel very natural to be able to just start writing desktop apps. ✍️ 💻
I skimmed though the transcript and it seems that that approach is not too dissimilar from the already existing https://github.com/cljfx/cljfx And to be fair, Hiccup itself is not that different in most aspects from just calling the things (and Hiccup also introduces new problems), which is exactly what https://github.com/clj-commons/seesaw does. Of course, not bashing the work that Nikita has been doing. But IMO it's worth pointing out that people that want to write desktop UIs in Clojure without CLJS have had working solutions for quite some time now.
you could always do this https://www.reddit.com/r/Clojure/comments/xof0id/tauri_clojurescript_shadowcljs/
I'm toying with some reagent code to understand how ratoms work internally. Here I assumed this component would re-render indefinitely – but it only renders once. Would appreciate any pointers on how reagent prevents this from looping.
(def an-atom (r/atom nil))
(defn a-component []
(fn []
@an-atom
(reset! an-atom (rand-int 1000))))
(defn main []
[a-component])
I would suggest to straight up read the implementation. Much more effective than trying to approach it as a black box. It's not that easy to follow, but possible.
But if I had to guess, it's probably because your component doesn't return proper Hiccup. Try wrapping @an-atom
in a [:span ...]
and return it from the inner function.
I tried this, doesn't loop either.
(defn a-component []
(fn []
[:div
[:span (reset! an-atom (rand-int 100))]
[:span @an-atom]]))
I'm working through the source slowly but steadily, will report if I figure it out 😄Why is there a second wrapping function call inside a-component? I think it's not actually evaluating the function but just trying to render a function as a value. Also, I suspect you want the reset to be for side-effects but not rendered in hiccup as I believe it just returns nil?
> Why is there a second wrapping function call inside a-component? It's a form-2 component, perfectly fine. > I believe it just returns nil? Doesn't matter in this case.
I understand it's a two form component, but why, it's not closing over the state of an-atom
so it's just complicating things for not a lot of reason.
like if an-atom was declared as a let around the fn I could see why it needs it but otherwise it's just kinda obscuring intent and complicating matters.
Sure, but if they are confused then it's helpful to simplify the setup until they understand it.
> Why is there a second wrapping function call inside a-component? Oops yeah, it doesn't need to be form-2. I was playing around with a let and then missed removing the fn. A form-1 component illustrates it just fine.