This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-03
Channels
- # announcements (1)
- # babashka (22)
- # beginners (176)
- # calva (10)
- # cider (4)
- # circleci (5)
- # cljsrn (20)
- # clojure (28)
- # clojure-europe (11)
- # clojure-italy (5)
- # clojure-nl (5)
- # clojure-spec (1)
- # clojure-sweden (2)
- # clojure-uk (29)
- # clojuredesign-podcast (4)
- # clojurescript (38)
- # code-reviews (25)
- # conjure (1)
- # core-typed (1)
- # data-science (16)
- # datomic (23)
- # figwheel-main (16)
- # fulcro (48)
- # helix (9)
- # jobs (3)
- # juxt (5)
- # kaocha (17)
- # malli (19)
- # mount (9)
- # nrepl (4)
- # off-topic (35)
- # pathom (7)
- # re-frame (28)
- # reagent (26)
- # reitit (1)
- # releases (1)
- # remote-jobs (5)
- # sci (6)
- # shadow-cljs (36)
- # spacemacs (3)
- # sql (8)
- # tools-deps (13)
- # unrepl (1)
- # vim (4)
- # xtdb (8)
What's the best way to load a file in Clojurescript? I'm trying to read an .env
file to retrieve my api keys.
there might be a lib but my first instinct would be to use platform interop - it's not hard to use node apis (or use the OS js apis on the slim chance you are using that instead of node...)
I'm actually not using Node. It's just a toy app I'm building to play around with cljs. The only library I'm using is Reagent.
I tried the environ lib but couldn't make that work. Tried a variety of things and could never get CLJS to recognize the library (I'm also using leiningen for what what that's worth)
if you aren't using node, which js vm is running your code?
if it's running in a browser, you can't read their files unless the user explicitly goes and provides it to the app, for security reasons
if you want to do this from the server, this is a clojure question and not a clojurescript one
Good question, I'm not actually sure. I'm using lein with the reagent template. I don't think it's running node under the hood. I'm actually trying to read my own .env
file in my project directory for the API key I'm going to use to hit a third party api.
OK then this is a clojure question, you can use slurp
in your clojure code (the part that runs on the back end)
Yeah I know you can use the io namespace in Clojure. Was hoping I could do something similar in CLJS. Bummer, thanks anyways!
cljs can't read data on your server, because it's running on the client's machine
if it could read files on your server, that would be a big problem
also, if its a secret, it can't go to a random person's browser. if it does, it's not secret since you've shared it
funny how secrets work that way isn't it
when I was first learning ot program I often thought things were safe because I would never figure them out
I underestimated how much more I'd know a few decades later
Gosh that's such a good point. Was too busy figuring out clojure I forgot the basics. Thanks for the help guys.
Hi. I've been using material-ui in my cljs. I have used Button, TextField components. But I cant use material-ui/MenuItem component. I want to use it inside material-ui/Select. My code is: (defn MenuItem [] [:> material-ui/MenuItem {:value "a"}]) ; :children "A"}]])) (defn Select [] [:> material-ui/Select {:defaultValue "Change Review event" :multiple true :values ["a" "b"]} (MenuItem)]) I get this error:
The above error occurred in the <ForwardRef> component:
in ForwardRef (created by ForwardRef)
in div (created by ForwardRef)
in ForwardRef (created by WithStyles(ForwardRef))
in WithStyles(ForwardRef) (created by ForwardRef)
in ForwardRef (created by WithStyles(ForwardRef))
in WithStyles(ForwardRef) (created by ForwardRef(Select))
in ForwardRef(Select) (created by WithStyles(ForwardRef(Select)))
in WithStyles(ForwardRef(Select)) (created by reviews_next.pages.feedback_event.feedback_event)
in div (created by reviews_next.pages.feedback_event.feedback_event)
in div (created by reviews_next.pages.feedback_event.feedback_event)
in reviews_next.pages.feedback_event.feedback_event (created by )
in div (created by )
in
Thanks @U2FRKM4TW, I have resolved the error. I had to change the :values
to :value
in Select component.
Hi all, I want to consume some es6 code from clojurescript, which doesn't come from a library - I mean the es6 code is just a local file. It is possible to require
a .js file from cljs when it is written with goog.provide
I know, but this code is written as an es6 module.
The Google Closure compiler is fine reading this es6 code when I invoke it directly (not via cljs compiler) and I have a demo of that here https://github.com/henryw374/cljs-using-non-foreign-es6, but I can't work out how to write the clojurescript require
so that it will work to read the es6 file.
I want this to work everywhere, including shadow so js modules https://clojurescript.org/reference/javascript-module-support is not going to be an option.
I'm starting to dig into the cljs compiler for answers but if anyone can give me some pointers it'd be appreciated 😉
I've asked about es6 import from google closure module on Closure forum so maybe that will provide the next clue
shadow-cljs supports this https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js
Hey, not sure if I am posting this on the right channel (its my first public message ever on this Slack), but in one of the projects I am migrating from cljs-time
0.4.0
to 0.5.2
and it seems that behaviour of cljs-time.coerce/from-string
has changed over the years, i.e.:
(cljs-time.coerce/from-string "2015-06")
=> #object[Object 20150106T000000]
Has anyone came across this? Not sure if this behaviour is expected? I'd expect 2015-06-01
, not 2015-01-06
. I can probably change the order of formatters used to parse dates, but I'd prefer not to.Seems like an inadvertent consequence of the fix at https://github.com/andrewmcveigh/cljs-time/commit/cb7cac6bbc934ab70baea9f0070198c6cc814b33#diff-e370ddc66eef0a72df61157a44d89eca
But "2015-06" is ambiguous either way. If you yourself know that it's definitely "yyyy-MM", then it's better to avoid from-string
altogether and just call cljs-time.format/parse
.
hmmm, cljs-time.format/formatters
contains an entry for yyyy-MM
, but unfortunately for me another formatter is chosen by parse-string
. So I will just assume the input is in yyyy-MM format and parse it as such, what seems doable. Thanks @U2FRKM4TW
couldn't you effect this by specifying a locale? it's a regional thing which order month/day are in right?
probably better to specify a precise ISO rather than locale actually
It feels like you could treat this as a valid RFC-3339 representation, just like #inst "2015-06"
works
Oh, wow, sorry about that. I didn't realize the date format for #inst
isn't really specified as ISO 8601, which allows for partial representations.
(RFC-3339 doesn't allow for what I suggested above.)
I guess the actual format of #inst
is a bit of an open question.
in java.time that would be the default format of a YearMonth, which is as ISO thing https://www.w3.org/TR/NOTE-datetime . using yearmonth entity you can convert into date etc. unashamed plug coming up: https://github.com/henryw374/cljc.java-time