Access defrecord methods in ClojureScript Figwheel

I have code in cljc files that compiles for both Clojure and ClojureScript.

in .cljc protocols

(defprotocol Transformable ".." 
    (scale [this scalar] "" ) ...)

in pattern.cljc

(defrecord APattern [paths]
    Transformable
      (scale [this s] (...)) ...)

in another.cljc

(defn f [pattern] (.scale pattern (/ 1 2)) )

And in core.cljs

(another/f pattern)

However, I get an error in the browser console

TypeError: pattern.scale is not a function

Checking the fields of the template object in core.cljs (using js-keys) shows me that the object has something called

"patterning$protocols$Transformable$scale$arity$2"

which looks like my function. So am I just doing something wrong to access it in ClojureScript? Does. notation not working? Do I need to do something?

+4
source share
1 answer

. f :

(require 'protocols)
(defn f [pattern] (protocols/scale pattern (/ 1 2)) )
+2

Source: https://habr.com/ru/post/1626172/


All Articles