nha nha - 1 year ago 132
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download