I've been able to export a Clojure function into the ClojureScript environment without too much difficulty. Ideally, I'd like to be able to call that function as if it were a regular ClojureScript function.
I was hoping I could do something like:
(extend-type js/Packages.clojure.lang.IFn
IFn
(-invoke [this] (.invoke this))
(-invoke [this a] (.invoke this a))
;; etc
)
However, this yields an error that I don't quite understand:
java.lang.UnsupportedOperationException: nth not supported on this type: Symbol
at clojure.lang.RT.nthFrom(RT.java:846)
at clojure.lang.RT.nth(RT.java:796)
at cljs.core$extend_type$assign_impls__7365$fn__7377$adapt_params__7380.invoke(core.clj:486)
at clojure.core$map$fn__4087.invoke(core.clj:2434)
In fact, I'm not sure this will work at all, since (type) doesn't appear to work with non-native JS objects.
Is the extend-type method feasible?
Cheers,
Stuart