clj->js can be used?

To solve this problem we can use clj->js function that: “Recursively
transforms ClojureScript values to JavaScript. sets/vectors/lists
become Arrays, Keywords and Symbol become Strings, Maps become
Objects.”

http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/

(def js-object (clj->js  :a 1 :b [1 2 3] :c #{"d" true :e nil}))

will produce such object:

{
  "a": 1,
  "b": [1, 2, 3],
  "c": [null, "d", "e", true]
}


On Tue, Aug 11, 2015 at 11:42 PM, Francis Avila <[email protected]> wrote:
>
> On Tuesday, August 11, 2015 at 2:05:12 AM UTC-5, Eduard Bondarenko wrote:
>> I think you don't need to nest #js, only one on start. Am I correct?
>
> You are incorrect. In fact, there needs to be one more #js for the vector to 
> make it a js array. Using threading can clean this up a bit too and make it 
> read more like the original js:
>
> (defn home-did-mount []
>   (-> (js/$ js/document)
>       (.ready (fn []
>                 (-> (js/$ "#example")
>                     (.dataTable #js{:columnDefs
>                                     #js[#js{:orderable false
>                                             :targets 0}]}))))))
>
> As for whether this is the best way to use dataTable with reagent, that I am 
> not sure about. The hardcoded "#example" is suspicious, probably better to 
> use a react ref or getDOMNode() instead if reagent exposes this.
>
> --
> Note that posts from new members are moderated - please be patient with your 
> first post.
> ---
> You received this message because you are subscribed to the Google Groups 
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to