view raw
nha nha - 9 months ago 67
Javascript Question

call ClojureScript from Javascript

How to call ClojureScript code from Javascript (not the other way around !).

It is already possible to call Clojure from Java, but I don't know how to do the equivalent in ClojureScript.


Export the functions you want to have available in js by using ^:export, then simply call it as my.ns.fn()


(ns hello-world.core)

(defn ^:export greet [] "Hello world!")



See the accepted answer to "Clojurescript interoperability with JavaScript" for detailed info.