I am working with Om and I didn't fully understand the following expression :
(.. e -target -checked)
Here, "e" is a javascript event, and "-target -checked" is a way to access properties, if I understood well. But what about the two dots at the beginning ?
That's one of the forms for clojurescript interop.
The most basic one is
(.method object) ; Equivalent to object.method()
(.-property object) ; Equivalent to object[property]
In order to access several nested properties, there is a shortcut with the ..
operator, so that you can do:
(.. object -property -property method)
(.. object -property -property -property)
Instead of:
(.method (.-property (.-property object)))
(.-property (.-property (.-property object)))
And the code results in a cleaner more readable expression. As you can see, the parallel is that the form is the same as normal interop but without the dot, so that property access turns into -prop
and method calls turn into method
(no dot).
Those forms above are equivalent to this JS forms:
object[property][property][method]()
object[property][property][property]
Read up this good post to learn more about clojurescript's javascript interop forms: http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With