Fork me on GitHub
Febin John James05:11:27

Is there any material on building a clojure wrapper for js library that's has an Object Oriented Design.


Define object oriented design


and maybe share the library in question


the benefit of doing a wrapper is usually pretty small unless you are using it extensively and its existing api is bad in some noteworthy way

Febin John James07:11:34

Someone has made a wrapper for this few years ago

Febin John James07:11:39

But it's old now.

Febin John James07:11:03

I am trying to make a wrapper for the latest version.

Febin John James07:11:08

If i use the library directly, i feel my clojure code is turning into something like OOPs instead of functional design.


How old is it now? If it's design is solid you can probably update it easier than writing a new wrapper


It mostly just seems to replace method calls with a protocol so access is uniform

Febin John James23:11:05

6 years. I will reach out to the author and ask him some directions. Thanks


I am trying to achieve register functions with macro apparently I am doing it wrong:

   [reagent.core :refer [adapt-react-class]]
   ["recharts" :as rc]))

(defmacro adapt-react [name class]
  `(defn ~name
     ([] [~name nil nil])
     ([opts] [~name opts nil])
     ([opts content] [(adapt-react-class ~class) opts content])))

(adapt-react "line-chart" rc/LineChart)
(adapt-react "pie-chart" rc/PieChart)
(adapt-react "label" rc/Label)


(defmacro adapt-react [name class]
  `(defn ~(symbol name)
     ([] [~name nil nil])
     ([opts] [~name opts nil])
     ([opts content] [(adapt-react-class ~class) opts content])))


Or replace the strings with symbols at the usage sites. An extra benefit - your IDE could pick those up.


But instead of doing all that, it's much better to just

(def line-chart (adapt-react-class rc/LineChart))


thank you. I didn't notice macro is not necessary at first place 🙂

👍 1

cljs.user=> (defmacro just-test [name x] `(defn ~name [y] (* ~x y)))
cljs.user=> (just-test (symbol "xtwo") 2)
Wrong number of args (2) passed to cljs.user/just-test at line 1 


why it says wrong number of arguements


and different error on my console


Because inside the macro, name is not 'xtwo, the symbol, but rather it's '(symbol "xtwo") - a list of a symbol and a string. Forms are passed as is to macros - they are not evaluated.


thank you again 🙂

👍 1

hey, I'm getting a weird error when trying out this in emacs error in process filter: nrepl-send-sync-request: Sync nREPL request timed out (op eval code (require 'figwheel-sidecar.repl)) error in process filter: Sync nREPL request timed out (op eval code (require 'figwheel-sidecar.repl)) the only hit I got is from archive, with no solution 😞 any ideas? if there's anything more up to date than this setup I could use that instead too


thanks for the link, I haven't found any solutions there though.. all of these link to "hey I have this problem" and no follow up


found kind of a workaround: the command that times out is pasted in the repl window, you can copy it and re-run it in the repl. timeout seems to be set from emacs/cider side so if you run it manually it'll succeed


for some commands I still get "nrepl not connected" but I guess that's another issue and I switched to which seems to work better :)


why is ns-publics a macro in Clojurescript ?


Because the required information does not exist at run time.