Hello,
I just realized that many of the cljs works well with js native arrays and objects. Things like filter and map operates well on JS arrays and some macros are a very convenient way to handle things.
This makes me question about two (I think) equivalent constructs:
(.. jsObject -prop1 -prop2)
(-> jsObject .-prop1 .-prop2)
(some-> jsObject .-prop1 .-prop2)
The obvious advantage of the latter is that if any of the property access returns a null value I will not receive an error trying to access a property of null.
According to your experience (and if such thing exists) best practices what is the more recommendable solution ?
I’m on a situation where I can use the last construct (using the some pipe) but I need to do it inside the scope of another similar macro. It works but I am not sure if it is a matter of luck or if it works fine because it is intended to be used this way:
(defn findServicesWithImage [imageName services]
(->> services
(filter #(=(some-> % .-launchConfig .-imageUuid) imageName))))