This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-03
Channels
- # adventofcode (151)
- # asami (34)
- # babashka (43)
- # beginners (111)
- # cider (2)
- # clj-kondo (6)
- # cljdoc (12)
- # clojure (140)
- # clojure-australia (10)
- # clojure-europe (14)
- # clojure-france (5)
- # clojure-gamedev (5)
- # clojure-nl (4)
- # clojure-uk (10)
- # clojurescript (20)
- # community-development (9)
- # conjure (1)
- # core-async (4)
- # cryogen (3)
- # cursive (2)
- # datomic (17)
- # emacs (9)
- # events (1)
- # fulcro (27)
- # juxt (8)
- # kaocha (2)
- # lambdaisland (14)
- # off-topic (23)
- # pathom (37)
- # pedestal (2)
- # re-frame (8)
- # reagent (8)
- # reclojure (9)
- # reitit (5)
- # reveal (34)
- # shadow-cljs (27)
- # spacemacs (10)
- # tools-deps (123)
- # vim (28)
- # xtdb (17)
So, I was looking at this question on SO: https://stackoverflow.com/questions/51121526/how-to-customise-the-print-function-for-native-objects-in-clojurescript
And I was wondering if there's any good documentation on helping me to understand how extend-protocol
and IPrintWithWriter
works. The official documentation is a bit too...terse.
Basically, I'm first trying to understand what object
is doing, as I thought a type needed to go there.
For some reason you should extend these symbols instead of the type - e.g. js/Object - I don’t remember why
As in this call:
(extend-protocol IPrintWithWriter
js/Symbol
(-pr-writer [sym writer _]
(-write writer (str "\"" (.toString sym) "\""))))
Oh, I guess I should tag @U4YGF4NGM
For some reason you should extend these symbols instead of the type - e.g. js/Object - I don’t remember why
Hi everyone, I have a CLJS
project using lein
and shadow-cljs
and I'm trying to learn spec
.
What is it I have to do to get generate to work in the REPL? I've set these:
1. Dev dependency on [org.clojure/test.check]
in project.clj
2. Requiring [cljs.spec.alpha :as s]
and [cljs.spec.gen.alpha :as gen]
in the dev/repl namespace cljs.user
3. In the REPL I am inside the cljs.user namespace and everything except gen works as expected
If I run some (s/def)
and check those with the s alias, that works fine! But if I try to use gen like in the documentation: (gen/generate (s/gen int?))
I get this error->
#object[Error Error: Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required]
What am I missing? Does this only work in clojure and not in clojurescript?I should add that I've tried requiring all kinds of different variations and checked other similar reports on this error, most say that it goes away with what I did in step #1, but for me it doesn't.
When using cljs.test, is there a way to provide test data that will be used inside test method? I'm doing something below, but seems like shadow-cljs :browser-test can't detect the test
(deftest "add"
(for [[x y sum] [[1 2 3]
[1 1 2]
[1 5 6]]]
(testing "should add two numbers"
(is (= sum (add x y))))))
@jaime.sangcap first, you should write (deftest add ...)
. Furthermore, you should probably use doseq
instead of for
since for
produces a lazy seq and isn't intended for side effects like testing.
Hey, how can I call cljs from node js ? I have some node code that needs to convert js objects to edn and I was wondering if I could call js->edn
from node (and more generally if I could write node modules in cljs and then use them from node)
Hello, not sure if this is the right channel, but I'm trying to generate a javascript extern to use with reagent. I'm following this guide from cljsjs: https://github.com/cljsjs/packages/wiki/Creating-Externs And this is the library: https://github.com/weknowinc/react-bubble-chart-d3 The thing is, when I try to use the extern generator (http://jmmk.github.io/javascript-externs-generator/) I add my dist file (https://cdn.jsdelivr.net/gh/weknowinc/react-bubble-chart-d3@0eaf1ecef5c0f7c9c8eba4d779e18cfeb10884ba/dist/react-bubble-chart-d3.js) but when I input the javascript object name (which I assume is BubbleChart) it tells me that the namespace cannot be found. Can anyone tell me what I'm doing wrong?
I'm not sure what exactly is wrong, but there's no externs inferences, specifically so you don't have to generate externs in advance.
Just add ^js
in front of every variable that has a JS object at the point of its declaration - it should do the trick.
(defn do-stuff [^js val]
;; `prop` will not be manged by optimizations.
(println (.-prop val)))
Same reason why CLJSJS is now basically obsolete - you can use NPM packages just as they are, without having to undergo extra steps. It's especially easy if you use shadow-cljs.
Some additional info: https://shadow-cljs.github.io/docs/UsersGuide.html#externs There are also guides out there that aren't specific to shadow-cljs.