This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (8)
- # atom-editor (8)
- # aws (1)
- # babashka (96)
- # beginners (128)
- # calva (7)
- # cider (12)
- # cljsrn (1)
- # clojure (75)
- # clojure-europe (28)
- # clojure-hamburg (2)
- # clojure-italy (7)
- # clojure-nl (7)
- # clojure-norway (3)
- # clojure-uk (13)
- # clojurescript (26)
- # conjure (2)
- # crux (17)
- # cursive (18)
- # data-science (7)
- # datalog (21)
- # datomic (9)
- # duct (15)
- # expound (29)
- # figwheel-main (14)
- # fulcro (59)
- # helix (4)
- # jobs (2)
- # kaocha (19)
- # leiningen (15)
- # luminus (4)
- # malli (57)
- # meander (2)
- # off-topic (2)
- # pathom (12)
- # pedestal (8)
- # re-frame (53)
- # reitit (9)
- # remote-jobs (1)
- # shadow-cljs (64)
- # spacemacs (1)
- # specter (2)
- # tools-deps (12)
- # tree-sitter (2)
- # vim (11)
I have a npm dependency, CodeMirror, which has a css file in it. The js guides say to do
@import 'codemirror/lib/codemirror.css'; but trying various combinations of require and import, I couldn't get that working in cljs. In the end I just copied the css file into my public dir and linked it from my index.html. Which is fine, but what would the proper way to do this?
I don't think you can import
.css into cljs... it's probably meant to be imported into your SASS/LESS/PostCSS bundle, to be merged with the rest of your css.
Linking it directly from
index.html should be fine, anyways. The only advantage of merging it with the rest of the css is that you save one request.
Hi. What is the difference between async/await in JS and the way promises are handled in Clojurescript? I am not really familiar with JS nor the whole front-end domain for that matter. I need to use a JS library that supports async and wondering if I can use promises, or need to do smth more complex.
Besides the point I suppose, what what are you trying to do (which library?)
In general though, you can 100% use promises in ClojureScript. To handle them, you just use
.then. Having said this, if you asking if you can use
async/await (which is a layer ontop of promises) in ClojureScript, I believe the answer is no.
BUT you can use
<p! from core.async which gives the same “feel” as async/await. More here: https://clojurescript.org/guides/promise-interop
So my original question about the library is just about whether the library requires the ability to use async/await, or if the library is built on promises. If it’s the latter, you should still be able to use the library in ClojureScript and then if you want you can use something like
> So my original question about the library is just about whether the library requires the ability to use async/await, or if the library is built on promises. Async/await is more or less syntactic sugar over promises. No library can require you use async/await. Async functions are just functions that return promises.
@U5K8NTHEZ thanks! @U6GNVEWQG great,
<p! is new to me, although I've read that people tend to stay way from core.async in CLJS because it's not so easy to understand/complex.
I will try to look for code snippets on how to use the library in question
<p! is pretty new in general 🙂 It was partially added because there was a bit of conversation around the need for async/await so David Nolen, and a few others who were suggesting that core.async could handle it, threw in this little helper.
> I’ve read that people tend to stay way from core.async in CLJS because it’s not so easy to understand/complex
This depends on how you use it 🙂 I wouldn’t reach for it always, rarely do I need to on the front end, but
<p! is pretty straightforward and I would argue not difference in “complexity” than
It would probably be useful to share a portion of your code and what you tried that didn’t work. Would make it easier for people to help.
Here's a gist with some sample code showing my type inference issues: https://gist.github.com/schaueho/99882da7e8130b2d93e0d8247741d20e The JS code I'm trying to use is SodiumPlus, an encryption library.
This does not fix the issue, unfortunately. I get the exact same
:infer-warnings like before.
(def ^js sodium js/window.sodium) (defn encrypt-test [plaintext] (go (let [nonce (<p! (.randombytes_buf sodium 24)) key (<p! (.crypto_secretbox_keygen sodium)) ciphertext (<p! (.crypto_secretbox sodium plaintext nonce key))] (println "key: " (.toString key "hex")) (println "cipher:" (.toString ciphertext "hex")) (println "decrypted:" (.toString (<p! (.crypto_secretbox_open sodium ciphertext nonce key)))))))
Yes, it does! Great idea that go will re-write things, I would never have thought of that in this context. Thanks a ton!
This is outrageous enough that I have to share... Sicmutils now works in Clojurescript! https://github.com/littleredcomputer/sicmutils
I haven't made a release yet, and I want this settle... but this gives us automatic differentiation, lagrangian + hamiltonian mechanics, and a generic, differentiable algebra package in clojurescript