Fork me on GitHub

Can someone explain the .- syntax to me? Example

defn atom-input [value] [:input {:type "text" :value @value :on-change #(reset! value (-> % .-target .-value))}])


I assume that's calling js functions?


it’s accessing a property on a javascript object


Right right.


the trick is that you need a special form in clojurescript because accessing a property in javascript isn’t a function call


yes, interop with js is...weird 🙂 At least me going in blind and finding my way through it. My first encounter with it was with this (juxt #(.getHours %) #(.getMinutes %) #(.getSeconds %))


But I guess it's the same with java interop, which I haven't used a ton of


I assumed it was interop, but i wasn’t sure and it can be hard to google for syntax. Thanks everyone


I’m about 2-3 years late asking this question, but what is it about react that makes it a bit hit in the clojure community? People like to say its “functional” but given how broad that definition tends to be it doesn’t really narrow it down for me. I recall being familure with these concepts when react first hit, but i haven’t done much in the last year.


so its all faded…


as I understand it, the thing that makes it a nice fit is that react’s virtual-dom + reconciliation algorithm makes for a nice fit with functional programming: the UI can be thought of as a pure function of state without worrying about how to mutate the dom to make it so


there’s a video of david nolen from the early days


(I hate the fact that so much interesting stuff is in video form. I don’t know of any other community that is as video focused as clojure.)


Yea. I would rather have a research paper on the topic at this point. The whole thing seems hard to understand. I need to sit down with someone that has really thought deeply about these things and has the historical context to frame where we are now and how we got there. Those people tend to have better things to do. lol!


Though i suspect there are lots of papers written on these topics, but they were probable written once, 15-50 years ago and now its just a matter of shouting it at people tell we all get the message.


Are the react diff changes scoped by components? or are those unrelated


I’m not sure I follow. React builds the virtual dom each time and compares it with the actual dom and then issues mutations


nice. I’ll take a look