This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-25
Channels
- # announcements (1)
- # asami (3)
- # aws (2)
- # babashka (8)
- # beginners (60)
- # biff (3)
- # calva (45)
- # clj-http (3)
- # clj-kondo (19)
- # clojure (50)
- # clojure-europe (23)
- # clojure-nl (8)
- # clojure-spec (4)
- # clojure-uk (3)
- # clojurescript (32)
- # conjure (3)
- # datomic (7)
- # events (2)
- # fulcro (24)
- # graalvm (3)
- # inf-clojure (3)
- # jackdaw (1)
- # lsp (3)
- # malli (8)
- # missionary (14)
- # off-topic (1)
- # polylith (3)
- # portal (11)
- # rewrite-clj (63)
- # shadow-cljs (21)
- # spacemacs (7)
- # tools-build (6)
- # xtdb (4)
Is there any material on building a clojure wrapper for js library that's has an Object Oriented Design.
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
Someone has made a wrapper for this few years ago https://github.com/dparis/phzr
But it's old now.
I am trying to make a wrapper for the latest version.
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
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:
(ns spill.tools.adapters.recharts
(:require
[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))
cljs.user=> (defmacro just-test [name x] `(defn ~name [y] (* ~x y)))
true
cljs.user=> (just-test (symbol "xtwo") 2)
Wrong number of args (2) passed to cljs.user/just-test at line 1
I've tested this on http://clojurescript.io
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.
hey, I'm getting a weird error when trying out this in emacs https://github.com/Gonzih/cljs-electron
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 😞 https://clojurians-log.clojureverse.org/clojurescript/2019-06-26
any ideas? if there's anything more up to date than this setup I could use that instead too
@U01UDS4A1K8 the Zulip slack-archive might be of help: https://clojurians.zulipchat.com/#narrow/stream/180378-slack-archive/search/nrepl-send-sync-request
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 https://github.com/ahonn/shadow-electron-starter which seems to work better :)
why is ns-publics
a macro in Clojurescript ?