Fork me on GitHub
#clojurescript
<
2022-03-14
>
Stuart10:03:03

What is preferred, and why is their is 2 ways to do this? A:

(cy.add #js {:data #js {:id "4" :label "INP\ntgt"}})
  
B:
(.add cy #js {:data #js {:id    "2" :label "INP\ntgt"}})
? Are they really just equivalent ?

rickheere11:03:56

As far as I know B is the real intended way. Version A is to let people who come from JavaScript feel more at home.

p-himik11:03:47

Don't use cy.add unless add is already in the externs: https://clojure.atlassian.net/browse/CLJS-3315 Personally, I use it only with js/console.log - because log is certainly in externs (built-in JS API) and I use that function very often (typing (.log js/console ...) requires a tad more mental effort).

Stuart11:03:10

thanks guys

thheller14:03:13

@U2FRKM4TW FWIW any length of js/whatever.x.y.z is safe in shadow-cljs. it just generates externs for all properties assuming its all ^js.

👍 3
thheller14:03:02

as for the other question always use .add obj style for anything that is not accessing a js/ global

👍 2