Fork me on GitHub
#clojurescript
<
2024-04-12
>
Vladimir Pouzanov08:04:47

Is this the most reasonable way to pass variable args down into the js world?

([q & args]
   (p/let [stmt ^js (.prepare @conn q)
           _ (.log js/console stmt args)
           q (apply (.bind (.-query stmt) stmt) (map clj->js args))
           _ (.close stmt)]
     q))
The whole apply thing feels a bit messy

1
thheller09:04:51

kinda hard to decipher what this is, but JS does have .apply as well. So likely you don't need this whole bind/apply combo?

Vladimir Pouzanov09:04:25

that's basically stmt.query(...args)

thheller09:04:02

stmt.query.apply(stmt, args)

Vladimir Pouzanov09:04:09

oh right. I never thought about the JS's apply, actually.