This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-23
Channels
- # announcements (7)
- # babashka (40)
- # babashka-sci-dev (74)
- # beginners (74)
- # calva (31)
- # cider (11)
- # clj-kondo (22)
- # cljs-dev (1)
- # cljsrn (1)
- # clojure (70)
- # clojure-brasil (3)
- # clojure-dev (12)
- # clojure-europe (39)
- # clojure-nl (2)
- # clojure-norway (15)
- # clojure-uk (9)
- # clojurescript (69)
- # community-development (2)
- # conjure (1)
- # core-async (3)
- # cursive (1)
- # data-science (1)
- # datalevin (13)
- # datomic (17)
- # emacs (42)
- # events (1)
- # fulcro (16)
- # graphql (9)
- # helix (1)
- # holy-lambda (14)
- # honeysql (2)
- # hugsql (3)
- # hyperfiddle (5)
- # kaocha (10)
- # lsp (41)
- # luminus (5)
- # malli (7)
- # meander (3)
- # membrane (47)
- # off-topic (23)
- # podcasts (2)
- # polylith (34)
- # rdf (4)
- # re-frame (2)
- # releases (2)
- # remote-jobs (1)
- # ring (16)
- # shadow-cljs (111)
- # spacemacs (6)
- # test-check (2)
- # tools-deps (19)
With the release of Clojure 1.11 and random-uuid being now present in Clojure I have looked into how random-uuid is implemented in CLJS as well and I think, we can get 2x better performance rather easily with this patch: https://github.com/clojure/clojurescript/pull/161
What do you think?
Given this
(def *a (clj->js {:foo {:bar 1}}))
How can I access :foo in the defined js object ?Should be (.-foo *a)
(.-prop obj)
is the ClojureScript equivalent to obj.prop
in JavaScript (property access)
But I do have a case where (.getMessage a) works but (a.getMessage) fails with
:repl/exception!
;
; Execution error (TypeError) at (<cljs repl>:1).
null is not an object (evaluating 'this.msg_'
The a in (.getMessage a) is actually a logRecord as in : https://github.com/google/closure-library/blob/605aa47173bfb01d7d989d3bbf4f2bcbc9d2088b/closure/goog/debug/formatter.js#L437
Not sure why this does not work in your case. Frankly, I prefer using the Clojure-style syntax. (.getMessage a)
would also work in Clojure
There is not a way to calculate test coverage for Cljs tests, right? (I feel like this is a retoric question after checking this channel history 😢 )
for the records I used some static analysis to answer my coverage questions: https://ag91.github.io/blog/2022/03/25/moldable-emacs-how-many-namespaces-are-covered-by-my-clojurescript-tests/
Can someone tell me if something looks obviously wrong??
(ns polka.webrtc
(:require-macros [cljs.core.async.macros :refer [go]])
(:require
[cljs.tools.reader.edn :as edn]
[reagent.core :as r]
[polka.testasync :as test]
[cljs.core.async :as a :refer [<! >!]]
[cljs.core.async.interop :refer-macros [<p!]]
[reagent.dom :as rdom]))
(defn simple-component []
(let [textArea (atom "")]
[:div
[:button {:on-click #(create-offer-start)} "Generate Offer"]
[:button {:on-click #(create-answer-start)} "Generate Answer"]
[:br]
[:textarea
{:value (.stringify js/JSON @textArea)
:on-change #(swap! textArea (.. % -target -value))}]
[:br]
[:button {:on-click #(set-remote-desc)} "Set Remote Desc"]
[:button {:on-click #(set-local-desc)} "Set Local Desc"]]))
But I am getting this error in the console in browser when I type in the text area:
cljs.core.js:16157 Uncaught TypeError: f.call is not a function
at eval (cljs.core.js:16157:89)
at Function.eval [as cljs$core$IFn$_invoke$arity$2] (cljs.core.js:16158:3)
at eval (polka.webrtc.js:971:29)
at Object.reagent$impl$input$input_handle_change [as input_handle_change] (reagent.impl.input.js:72:106)
at eval (reagent.impl.input.js:127:27)
at HTMLUnknownElement.callCallback (module$node_modules$react_dom$cjs$react_dom_development.js:653:470)
at Object.invokeGuardedCallbackImpl (module$node_modules$react_dom$cjs$react_dom_development.js:655:442)
at invokeGuardedCallback (module$node_modules$react_dom$cjs$react_dom_development.js:56:424)
at invokeGuardedCallbackAndCatchFirstError (module$node_modules$react_dom$cjs$react_dom_development.js:57:49)
at executeDispatch (module$node_modules$react_dom$cjs$react_dom_development.js:111:250)
:dependencies
[[reagent "1.1.1"]]
You're trying to use the value of the textarea as the function here
ah nice @UPHKPR2A3 thanks,. I no longer get the error, but i'm still not seeing the text change in the textarea
Shouldn’t this be a form 2 component instead?
Or let-with
I believe?
Or r/with-let
, as an alternative to a form-2 component, yes. Still gotta be a ratom though.
@U037ENVB11C - https://github.com/reagent-project/reagent/blob/master/doc/CreatingReagentComponents.md
awesome, thanks @U2FRKM4TW!
I also highly recommend http://timothypratley.blogspot.com/2017/01/reagent-deep-dive-part-1.html
slightly dated, but still relevant
oh looks great @U8VE0UBBR thanks. Im going to go through today. My tabs are scary right now 🥲
My recommendation, not that it counts, is to never solve an issue without understanding it thoroughly, deadlines be damned.
This is for my own project so i'm doing a mixture. Jamming as far as I can get till I get stuck, then dive deep into the stuff I don't know with at least some context
How am I supposed to deal with uncaught errors originating in async code? It just prints some messy object that says "promise error". The stacktrace is just a bunch of async internals.
I kinda know which function it's coming from...
But IIRC you just straight up can't use exceptions in async code, and there was also weird stuff where you can't have an async operation across a try boundary or something?
I would love to use the new :as-alias
(new in Clojure 1.11.0) in Clojurescript. But I don’t understand enough about the interplay between Clojure, Clojurescript, and (in my case) shadow-cljs to know how to make it work, or if it is even within my power to do so. All I know is I get compilation errors when I try to use it in my full stack project in .cljs files. Works great for the Clojure side of the project.
I think I’m using the latest version of shadow-cljs, so why isn’t it working for me? How do I troubleshoot this?
if you use :lein
or :deps
in shadow-cljs.edn
then the version is in project.clj
or deps.edn
I figured it out. The local package had latest version, but I was using global install that was out of date.
Hah! I probably ran that global install over two years ago and then never realized or thought about it. This may explain some other oddities I’ve noticed but weren’t annoying enough to go track down and figure out. Thanks for your help @U05224H0W, and for the most awesome shadow-cljs.
oh yeah don't let it get that far out of sync. a couple minor versions is probably fine but not too long
well technically there has only been one breaking change in the global install in the last 4 years or so
so there usually is no issue in having the global install out of sync. but just to be save using npx shadow-cljs
over just shadow-cljs
prevents this issue
hello, I'm trying to use re-com and I'm still trying to wrap my head around the tooling. In their README it says "You'll then need to include these asset folders in your app: https://github.com/day8/re-com/tree/master/run/resources/public/assets". Should I manually copy those files to my assets folder, or are they supposed to be extracted from the package by some build tool?
re-com
jar is a part of your classpath during the build process - you can set up a build tool to incorporate those assets into your app. Either by embedding into other assets or by simply copying them.
Same deal with NPM packages - if they have CSS there, you can incorporate it during the build process.
I see, I'm using shadow-cljs, but I don't think it has that kind of functionality, does it?
Asset management is out of the scope of shadow-cljs. However, it has build hooks which can run external programs - you can either bundle your CSS with them or just copy the files around. I think @U05224H0W mentioned at some point that he doesn't think that it's a good use of hooks and that instead something else should be used. Thomas, could you please confirm if I remember correctly and what that other thing is?
asset "bundling" is not supported. but this sounds like it just wants to load some stuff
for a production server you have to do this yourself. for development you can use :dev-http {8000 "classpath:public"}
depending on what you want to do hooks can make sense. most of the time there are better options though
Do they make sense as part of the release step to build SCSS (and make the SCSS compiler grab all the CSS from relevant NPM modules) and to copy some other resources from node_modules
to an in-app dir?
I'll look into hooks and see if that makes sense. Thank you so much for your help!