This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-08
Channels
- # announcements (5)
- # babashka (46)
- # beginners (32)
- # calva (9)
- # chlorine-clover (4)
- # clojars (31)
- # clojure (83)
- # clojure-italy (1)
- # clojure-nl (1)
- # clojure-spec (13)
- # clojure-uk (12)
- # clojuredesign-podcast (1)
- # clojurescript (30)
- # cursive (3)
- # fulcro (18)
- # graalvm (6)
- # graphql (2)
- # jobs-discuss (6)
- # joker (4)
- # malli (1)
- # nrepl (1)
- # off-topic (15)
- # shadow-cljs (2)
- # spacemacs (3)
- # tree-sitter (19)
- # vim (1)
- # vscode (7)
I’ve been using records in clj-land and converting them into maps to send in cljs-land, because edn doesn’t handle records.
I’ve been using records because most of the material I’ve read couples that with protocols.
Now I’m hitting what appear to be slowdowns entirely due to conversion, should I:
1) Use transit or some flavor of that (not sure how this works with records)
2) Hand write custom conversion functions
3) Be just using raw maps and multimethods
4) Be doing this all some other way
The cljs side code doesn’t care other than what it gets sent is maplike, as all it needs to do is render it. The clj side does need to be able to do some dispatch based stuff as I am periodically processing the datastructure to get my next state.
This is happening over sente if that helps…
I’ve spent some time looking at
, but not sure if I should be spending time converting that to cljc.
Ok, well that answers that =)… I don’t need records, however pretty much all the stuff you see online talks up records+protocols over multimethods, and much of the time the framing appears to be why oh why would you ever use multimethods, they’re just a poor man’s protocol…
more concretely:
protocols: theoretically faster, more limited (can only dispatch on type of the first arg), can syntactically group a few fn together (e.g. push
and pop
on an IQueue
protocol)–though there is no guarantee that all fns will be implemented
multimethods: theoretically slower, more flexible (can dispatch on anything), no syntactic grouping (but you can group by convention or document a grouping)
how to add externs to all :cljsbuild
builds?
@potetm, probably reading this in different places to you =)… What I’m working on here is more in gamedev/sim space and it seems most of the things I’ve seen frame it the way I’ve described, default I’ve seen is records/protocols =)…
Does anyone have any experience with scanning QR codes? I’ve tried react-qr-reader
which I’ve managed to make work, but the worker fails to recognize any of QR codes I’ve tested it with… I’ve tried to have it scan the QR code from the wikipedia article on QR codes and it failed to detect that. Does anyone have any particular JS QR code reader library they like?
Has anyone worked with puppeteer and clojurescript?
Im getting this issue when trying to write clojurescript in
page.eval()
Error: Evaluation failed: ReferenceError: cljs is not defined
`at puppeteer_evaluation_script__:4:1`
if i rely on javascript only within evaluate
:
(.stringify js/JSON (.-localStorage js/window))
i get no errors.(defn check-for-error [page]
(.evaluate page (fn [_]
(let [selector "myselector"
element (.querySelector js/document selector)]
(js/console.info element)
(when element
(.-innerHTML element)))) 1))
@U08E3BBST awesome! here is the function that is failing.and do you really have cljs libraries present in the page’s js context? try to eval “typeof cljs” (js code as string)
the code you wrote compiles to "function (_){\nvar selector = \"myselector\";\nvar element = document.querySelector(selector);\
, which needs cljs runtime present
tried to eval it, got:
Error: Evaluation failed: ReferenceError: cljs is not defined
`at puppeteer_evaluation_script__:2:1`
Thanks @U08E3BBST for the assistance. I will check out how to do it 🙂, im quite new to the puppeteer api.
looks like page.addScriptTag
is what im looking for
e.g. here https://github.com/binaryage/cljs-devtools/blob/master/test/resources/run-tests.html#L7
and then tell puppeteer to open that url: https://github.com/binaryage/cljs-devtools/blob/master/test/resources/puppeteer.js#L39
I don't think I can do it your way since I am running puppeteer against a non-test-environment website
btw. in your evaluate code snippet you don’t seem to rely on cljs that much, why not writing it in plain js?
yeah that sounds like a great idea I had the same thought. so I would just js/eval a javascript string?
your trouble is that the emitted code contains a call to “cljs.core.truth_” which is not essential to what you are trying to do there
I see, I wrote some vanilla js to solve the problem. 🙂