Fork me on GitHub
#reagent
<
2018-06-02
>
Drew Verlee00:06:21

Can someone explain the .- syntax to me? Example

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

Drew Verlee00:06:16

I assume that's calling js functions?

justinlee00:06:39

it’s accessing a property on a javascript object

justinlee00:06:28

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

theeternalpulse00:06:49

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 %))

theeternalpulse00:06:41

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

Drew Verlee21:06:25

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

Drew Verlee21:06:09

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.

Drew Verlee21:06:14

so its all faded…

justinlee21:06:08

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

justinlee21:06:17

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

justinlee21:06:47

(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.)

Drew Verlee21:06:27

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!

Drew Verlee21:06:22

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.

Drew Verlee21:06:28

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

justinlee21:06:07

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

Drew Verlee22:06:43

nice. I’ll take a look