This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-28
Channels
- # announcements (11)
- # aws (2)
- # babashka (35)
- # beginners (173)
- # calva (3)
- # chlorine-clover (2)
- # cider (17)
- # clara (2)
- # clj-kondo (28)
- # cljs-dev (11)
- # cljsrn (53)
- # clojure (178)
- # clojure-argentina (1)
- # clojure-europe (12)
- # clojure-germany (5)
- # clojure-italy (4)
- # clojure-nl (5)
- # clojure-spec (25)
- # clojure-uk (88)
- # clojurescript (109)
- # conjure (34)
- # cursive (2)
- # data-science (35)
- # datomic (15)
- # emacs (6)
- # events (1)
- # fulcro (28)
- # graphql (15)
- # helix (21)
- # hoplon (7)
- # jobs (4)
- # jobs-discuss (1)
- # joker (15)
- # lambdaisland (1)
- # lein-figwheel (4)
- # local-first-clojure (1)
- # malli (8)
- # meander (17)
- # off-topic (33)
- # parinfer (2)
- # rdf (16)
- # re-frame (3)
- # reagent (21)
- # reitit (14)
- # remote-jobs (5)
- # ring (8)
- # rum (1)
- # shadow-cljs (184)
- # sql (2)
- # testing (1)
- # tools-deps (23)
How does one inject secrets and other configuration parameters into a clojurescript browser app at build time? Is there a way to have a config.edn file in the local filesystem of the build machine that can be read in or otherwise made available at runtime of the app? I’m using shadow-cljs.
Well, yeah, I know it wil be in the browser. Its temporary. I just don’t want to check them into git.
Also looking for a what the recommended way is to have config stuff from a file for clojurescript
I like this from shadow: https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745
combine this with closure defines you can swap out config. remember anything you put in cljs will be shipped and run on someone else's machine and should not be considered secret
Understood about how not secure it is browser wise. The path is relative to the ns/file its in or the :paths?
@grumplet https://www.surveymonkey.com/results/SM-CDBF7CYT7/ if you look at the #1 problem for ClojureScript users it's using libraries
also shadow-cljs has become immensely popular in a relatively short time because it makes this considerably easier to do
that alone isn't a reason to do it, but it means that's something is missing because you can't do it that easily with ClojureScript itself
whether that means ClojureScript projects will be bloated or not is somewhat besides the point
maybe you're doing something for React Native where the payload is less important etc.
the other thing is that the only other way to do it easily prior to :bundle
is community maintained repo - CLJSJS
the maintenance burden is non-trivial - Bower for JS eventually went away because it's really not that sustainable to curate everything
I could go on - but I think you get picture - there are many reasons for and few against
sure Webpack can consume it, but many many other tools can also consume this kind of output
bundlers come and go, but I'm pretty confident the Node ecosystem isn't going anywhere
@grumplet but maybe you aren't complaining now that I read your statement more closely 🙂 yes if you want to use crazy libs it will just work
Is the only way to “hydrate” an edn expression in Clojurescript is to import a self-hosted cljs to do an eval? Or is there something I’m missing?
also take a look at https://github.com/juxt/aero which provides reader conditionals that provide different functionality based on environment variables or values passed in while reading the edn.
I'm running a clojurescript test using the cljs.test/run-tests command, and it contains the following test:
(deftest individual-field-test []
(db-refresh)
(dispatch [:checkout-fields :full-name "Some Name"])
(testing "individual field"
(is (= '([:full-name "Some Name"])
(filter (comp some? val) @checkout-fields)
))
)
)
When running the test, the dispatch doesn't seem to trigger and the assertion fails. However when I individually evaluate the dispatch and check the value of (filter (comp some? val) @checkout-fields), it is equal to '([:full-name "Some Name"]), which is what it should be.
Why is the dispatch not being triggered in cljs.test?@pshar10 is that re-frame? if so, you need macro from https://github.com/day8/re-frame-test
This works, but for convenience I tried creating a macro like so:
(defmacro deftest-sync [name test]
`(deftest ~name ~(run-test-sync ~test))
)
But when I do:
(macroexpand '(deftest-sync some-test (is (= 1 1))))
It simply outputs
(deftest-sync some-test (is (= 1 1)))
Which is unexpected. What am I doing wrong?@dnolen - Definitely not complaining - rather the reverse - sorry if it came over like that - I was simply experimenting and reporting on an awkward lib that had previously proved troublesome and was happy to see that it did just work. So, great work 🙂
I have this following idiom in my code:
(deftest my-test
(run-test-sync
(is (= 1 2)) ;; etc.
)
And it seems like a good idea to create a macro which would replicate this like so:
(deftest-sync my-test
(is (= 1 2))
)
And I have tried this:
(defmacro deftest-sync [name test]
`(deftest ~name ~(run-test-sync ~test))
)
But on doing in the shadow repl:
(macroexpand '(deftest-sync some-test (is (= 1 1))))
I simply get the result:
(deftest-sync some-test (is (= 1 1)))
But I seem to get the correct result in a clojure repl. Why would this be?I have an myapp.environment namespace like so in an environment.clj file.
(ns myapp.environment
(:require [myapp.config :refer [env]]))
(defmacro myapp-url [] (:myapp-url env))
Then I require this in an events.cljs file like
[myapp.environment :refer-macros [myapp-url]]
I get the error
The required namespace "myapp.environment" is not available, it was required by "myapp/events.cljs".
"myapp/environment.clj" was found on the classpath. Should this be a .cljs file?
when using it like so:
(http/get (str (myapp-url) "/somepath"))
How do I fix this?Did you try
(ns myapp.cljs-file
(:require-macros [myapp.environment :refer [myapp-url]]))
?
I think the :refer-macros
might only work on a .cljc
file , but that's just a WAGmyapp.config
doesn't happen to be cljs, does it? if so, might want to make that .cljc
otherwise environment.clj
won't be able to import it
Hello , how i can do this await client.connect(); in clojurescript? i am new in clojurescript and javascript
await is alternative syntax for a promise
what's the async function you're using it in?
usually something like
async function(blah) { await derp = something(); return derp }
it would be something like
(let [p (js/Promise. (fn [resolve] (-> (.connect client) (.then #(resolve %))))]
(-> p (.then (fn [] (comment "your code here")))))
agreed but wanted to keep syntax basic ... how would you do it?
I like it
to have a simpler syntax you'd need a macro right?
I don't know if it can get simpler but you could use externally bound resolve
/`reject` functions to change the pattern over to something like core.async
I do that on longer chains of .then
where I need to pass scope around
wouldn't make sense here. I like @thheller’s approach
I would not consider external resolve
more simple though >.<
> @takis_ if you really want async / await syntax you can use core.async https://clojurescript.org/guides/promise-interop
for trivial stuff it's not needed, but if your code is heavily async then this can help
wow I have never seen that before
I have some really annoying service worker code I need to try that on
that page is new
the core.async stuff was just added in the last release
@alexmiller I didn't know you hung out in #clojurescript ! you're everywhere 😄
Keeping an eye on the riffraff?
wonders what other cool cljs stuff came out this release
It will be helpful if the guides when they were added and when they were last modified.
generally, I'm not sure that it would
many guides are about things that are not new, and thus their creation date is not relevant
I update guides on the clojure site literally every week based on issues or whatever, but those changes might just be typos or something
the approach we more commonly take is to annotate in a guide when it became relevant
if you want a changelog, you can find that at https://github.com/clojure/clojurescript-site/commits/master
I said that in the context of this guide: https://clojurescript.org/guides/promise-interop At a glance it is not clear when it became available. (The promise interop looks really nice!)
I believe the top half of that page is new content but something that has been like that for a while. The bottom half could probably use an annotation about which version of core.async it was added in
(1.1.587)
If you'd like, feel free to file an issue on the clojurescript-site or become a contributor and file a pull request
Do changes/additions to documentation constitute a large or small change?
depends if they are large or small :)
:rolling_on_the_floor_laughing:
the question is really whether you can sufficiently review your change in the github asciidoc view or not
I would say most changes are "small" and you don't need to actually build and view the site to satisfy yourself
David and I can both make those style touch-ups if needed too
just wanted to offer how to do https://clojurescript.org/guides/native-executables from a tools-deps perspective since that document didn't work for me
sometimes it's better to start with an issue describing the problem
and then get feedback before a pr
works for me 🙂
Hello all, how do I convert this
import { Responsive, WidthProvider } from 'react-grid-layout';
const ResponsiveGridLayout = WidthProvider(Responsive);
to cljs?(def width-provider (reagent/adapt-react-class js/window.ReactGridLayout.WidthProvider))
(def responsive (reagent/adapt-react-class js/window.ReactGridLayout.Responsive))
(defn responsive-grid-layout []
[width-provider responsive])
something like that@fabrao it’s not possible to tell you why it’s not working without more information. e.g. what “not working” means
(ResponsiveGridLayout #js {:layouts {:lg {:x 0
:y 0
:w 100
:h 100
:i "1"}}}
(d/div {:key "1"} "Fernando"))
Cannot call a class as a function at Object.WidthProvider
This is the way I think it works
($ ResponsiveGridLayout {:layouts (into-array [:lg {:x 0
:y 0
:w 100
:h 100
:i "1"}])}
(d/div {:key "1"} "Fernando"))
Does anyone use respo? I myself use reagent because it seemed like an obvious choice when I first started using cljs. Are there any pros and cons for using respo instead of reagent?
@dnolen https://clojurescript.org/guides/promise-interop this is really slick. My 🎩 off to you and your team. Very elegant solution to this callback hell problem