I am using a custom clojure predicate function
in query
and my code is in a cljc file
when included on clj, it works fine
when included in cljs side it complains Unknown function
I have given the full namespace/fn-name
I see a test in test/datascript/test/query_fns.cljc
in code
(defn sample-query-fn [] 42)
#?(:clj
(deftest test-symbol-resolution
(is (= 42 (d/q '[:find ?x .
:where [(datascript.test.query-fns/sample-query-fn) ?x]])))))
Not sure why just a clj version is defined ? and not for cljs ?
aah in the src/datascript/query.cljc
I see
(defn- resolve-sym [sym]
#?(:cljs nil
:clj (when (namespace sym)
(when-let [v (resolve sym)] @v))))
So no resolutions for cljsJust passed the function as variable and then it worked 🙂 Just like the way its done here
(testing "Returning nil from function filters out tuple from result"
(is (= (d/q '[:find ?x
:in [?in ...] ?f
:where [(?f ?in) ?x]]
[1 2 3 4]
#(when (even? %) %))
#{[2] [4]})))