Clojurescript - #js 的部分功能

Clojurescript - partial function to #js

我正在调用具有三个参数的本机函数:nativeFunction(success, error, options);

我有一个像这样的 public ClojureScript 函数,包装调用 :

;; this works but I can't separate the success from the failure
(defn ^:export publicFn [cb]
  (nativeFunction. cb cb #js {}))

;; this doesn't work
(defn ^:export publicFn [cb]
  (nativeFunction. (partial cb js/undefined) cb #js {}))

所以应该这样称呼:myNs.publicFn(function(e, s) {console.log(e, s);});.

换句话说,我希望能够从 ClojureScript 中的双处理程序约定转换为第一个错误参数约定,同时与 Javascript.

兼容

可能吗?

嗯,我一定有一些其他代码 运行,或者可能有冲突,因为以下解决方案有效:

(defn ^:export publicFn [cb]
  (nativeFunction. (partial cb js/undefined) cb #js {}))

我可以像这样从#js(错误JavaScript)调用它:

myFn(function(e, d) { console.log(e, d); } );