This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-03
Channels
- # aleph (6)
- # announcements (4)
- # babashka (73)
- # beginners (117)
- # calva (25)
- # chlorine-clover (59)
- # cider (21)
- # clara (3)
- # cljdoc (8)
- # cljs-dev (54)
- # cljsrn (15)
- # clojure (65)
- # clojure-france (5)
- # clojure-spec (3)
- # clojure-uk (13)
- # clojurescript (79)
- # conf-proposals (1)
- # conjure (17)
- # core-logic (11)
- # datomic (21)
- # fulcro (82)
- # graalvm (11)
- # helix (7)
- # jobs-discuss (11)
- # joker (2)
- # juxt (3)
- # local-first-clojure (1)
- # luminus (5)
- # nrepl (61)
- # off-topic (12)
- # pathom (70)
- # re-frame (3)
- # reitit (3)
- # rum (1)
- # shadow-cljs (58)
- # sql (1)
- # tools-deps (26)
- # xtdb (3)
That isn't helpful. client.cljs isn't one of my src files. That might be one from the template that I'm using
its in the browser console so you should be able to click it and it'll take you to the source?
Is there a way to get a cljs map or vector of a Javascript Object’s properties? I tried
(.entries js/Ojbect myObject)
But I always get an empty vectorit’s included by default with cljs
you may have to require something like [goog.object :as gobject]
and use (gobject/getKeys obj)
Morning,
I tried adding a JS library to the re-frame template.
I used npm install --save aws-amplify
and then added ["aws-amplify" :as aws]
.
But the site doesn’t show anything and the console only shows the error:
reload-failed Error: Failed to load website/core.cljs:
at Object.shadow$cljs$devtools$client$browser$do_js_load [as do_js_load]
...
Does anyone know what I am doing wrong?
Edit:
Hmm I can import math-random
so I think it is an issue with aws-amplify
itself 😞it failed to load website/core.cljs
but that might be because an error in another file it depends on happened first
I was using it like:
["@aws-amplify/core"
:refer [Hub]
:default Amplify]
Depends a bit on what you want from the very large library. Also they recently dramatically changed the library in 3.x.x with the ability to load only the portion you want/need.
That have some javascript examples in https://github.com/aws-amplify/amplify-js and I find this a good guide to translating the import statements to Clojure require: https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html@jakob.durstberger I wrote up a tutorial on using Amplify Auth and re-frame https://dev.to/rberger/aws-amplify-and-clojurescript-re-frame-part-1-3d3f It was pre amplify 3.x but I think its generally applicable still
I want to use the authentication part, I’ll have a look at your post. Thank you
I went through your blog post and my issue is that the auth UI is just not coming up. I use terraform to deploy my user pool so I think I might have misconfigured something. Out of interest, did you also write this one?https://www.omnyway.com/add-serverless-aws-amplify-authentication-to-a-clojurescript-re-frame-app/ They seem to be very very similar 😄
Hi Jakob. Are you trying out the new webpack feature? https://clojurescript.org/guides/webpack
Uhm, not that I am aware of. I think the re-frame template doesn’t use webpack
Using node deps involves a bit of work. The most recent release opened up a new way but it's always been possible.
This is possibly the shortcut: https://github.com/cljsjs/packages/tree/master/aws-sdk-js
Assuming it's a recent enough version
No personal experience. The cljsjs project is a manual effort to package up JS deps so they are easy for clojurescript projects to use.
Adding math-random
and using it was super easy, so I think it actually is an issue with aws-amplify
I had a look at aws-sdk-js
and it seems like that is for talking to AWS services.
I am new to the whole amplify thing but I think it is something slightly different.
yeah, sorry. Bad google.
no worries 🙂
I wonder if you had the right dep. If it's a re-frame app perhaps you need @aws-amplify/ui-react
Just having a quick look here. https://docs.amplify.aws/ui/q/framework/react
For what it's worth those libs didn't immediately work for me via the webpack tutorial.
No I lied. They seem fine.
I'll post a little repro in case it's helpful.
My test was to print to console confirming I could see stuff in both libs
Good luck
Thank you, I’ll have a look at your repo
I reverted all my changes and started from fresh and interestingly enough if I just add aws-amplify
I can’t even compile the project because http2
is missing. When I add that dependency I am back to it compiling but not running, just frustrating 😕
@jakob.durstberger if you get an error about http2 missing then you need to bump your shadow-cljs version. that was fixed not too long ago.
Interesting. I bumped the shadow-cljs version from 2.8.83 to 2.8.109. Now I just get
Syntax error (NoSuchFieldError) compiling at (shadow/cljs/devtools/api.clj:1:1).
ES3
Full report at:
/var/folders/02/3d17l0kx4gd8ywt0zgstlqmw08dm4y/T/clojure-13818416195260001911.edn
Error encountered performing task 'do' with profile(s): 'dev'
Suppressed exit
make sure the shadow-cljs version matches the clojurescript version it expects ... or just use shadow-cljs.edn to manage deps which takes care of things like these ...
you likely have an old one specified in deps.edn or project.clj (whichever you are using)
yeah, there is an older one in my project.clj. I’ll try updating that too
Ok, I updated shadow-cljs and clojurescript. Now it isn’t complaining about http2 but process
Is that expected?
do you have the shadow-cljs npm package installed in the project? so not just the global install?
hmm yeah. I guess I should also update that one.
version of that package isn't the issue here. it also bring in the node-libs-browser
package which provides the process
and other node built-in polyfills
I ran lein new re-frame website +10x +cider +test +garden
Seems like it works now.
I was able to import amplify and call (.configure Amplify config)
Thank you so much @olivergeorge and @thheller for your help.
👍 Thomas has your back. I didn’t realize you were using ShadowCLJS
The whole clojurescript ecosystem + re-frame is new to me so I am not certain yet what is and isn’t important when I ask for help
How do I create a non-blocking suggestions input bar? So basically I'm taking in input and then making a get request using that input. But this blocks the input itself, which I don't want. So when typing the input hangs until the get request is made. Here's the code:
(reg-event-db
:update-address-zip-suggestions
(fn [db [_ suggestions]]
(prn "updating suggestions to" suggestions)
(assoc db :address-zip-suggestions suggestions)
))
(defn update-address-zip-suggestions [suggestions] (dispatch [:update-address-zip-suggestions suggestions]))
(reg-event-db
:user-address-suggestions
(fn [db [_ zip]]
;; this seems to be blocking
(go
(let [response (<! (http/get (str (my-url) "/address-zip-suggestions") {:query-params {:text (:user-address-zip db) :token "randomtoken"}}))
suggestions (:body response)]
(if (not (empty? suggestions))
(update-address-zip-suggestions suggestions)
)
)
)
db
))
(defn user-address-suggestions [address-zip] (dispatch [:user-address-suggestions address-zip]))
(reg-event-db
:user-address-zip
(fn [db [_ zip]]
(user-address-suggestions zip)
(assoc db :user-address-zip zip :address-zip-suggestions-shown? true)
))
(defn user-address-zip [user-address-zip] (dispatch [:user-address-zip user-address-zip]))
(defn address-zip-field []
[:input (tw style/text-input {:placeholder "Enter Address or Zip Code"
:on-change
#(user-address-zip (-> % .-target .-value))
})])
How do I make it not block? So that the input doesn't hang or wait for the get request to finish?What should I use for a new re-frame+leiningen+shadowjs project for adding npm dependencies? https://clojurescript.org/guides/webpack OR lein-cljsbuild OR lein-npm OR lein-shadow? This is rather confusing. Trying to follow various blog posts and it still fails to find a dependency: > The required JS dependency "@material-ui/core/Button" is not available, it was required by "foo/views.cljs".
the lein-shadow plugin lets you put the shadow-cljs stuff inside your project.clj file but all it does is just copy it right back out into a shadow-cljs.edn file. No real benefit from my eyes.
@nfedyashev with shadow-cljs it is just npm install the-package
and use it. nothing else. unfortunately some tempaltes try to move that functionality into project.clj via lein plugins which I do not recommend
I've been trying to get a bootstrapped/self-hosted cljs repl in the browser with no server. I've found a few projects related to this: https://github.com/cgrand/cljs-js-repl https://github.com/arichiardi/replumb They both haven't seen commits in awhile, I'm curious if anyone knows if these type of approaches are still the way to go or if there have been any changes to cljs in the past few years that would make this easier or these approaches obsolete? On a more philosophical level, what is a repl exactly? Obviously read/eval/print. But it seems in clojure/script there's also the state related to namespaces which is separate from those steps. Also the ideas of an input/output stream. I'm having trouble building up intuition around this. I've started trying to read the related cljs source. Anyone happen to have any good reading material related to this?
Hello clojurian, I m using shadow cljs in my journey to learn clojure/clojurescript. in development mode my server is running on port 3000 and shadow cljs server is at 8080. I m trying to proxy my api request to my server, here is what how i m trying to config proxy url. but it giving 404 error. Please help me with what im doing wrong?
:dev-http {8080 {
:root "target/"
:proxy-url ""}}
why are you using a proxy in the first place? why not just have your server on :3000 serve the output files? its just static files you need to serve, nothing else.
thanks you so much of shadow cljs @thheller , I m pleasantly surprise to get the answer from the greater of shadow cljs it self. Honoured Just one confusion about that how the hot reloading will work, if I serve the output of shadow cljs from my api server? thanks again for the answer.
that is running over the default shadow-cljs server regardless. it connects over a websocket (normally running on :9630)
so you can just make your regular server serve the file. it does not affect hot-reload in any way
Thanks @thheller I got it, will try it out.
@umardaraz4747 there's a dedicated #shadow-cljs channel for specific questions around shadow config, this is a more general channel
Thanks @U050B88UR I m honoured to hear from you!
if you have a lot of patience you could look at the ClojureScript source itself, those other projects depend on the fundamental support in ClojureScript so they're still relevant
the state stuff is compiler state, input/output stream are less relevant, bootstrapped ClojureScript works on strings
understood about it being advanced. I've had it "working" for a bit for my eval needs, just trying to take my understanding to the next level and was wondering if I was missing anything in my google searches 🙂
Hi! Is there an apply
analogue for javascript functions? I found js-invoke
but that can't be called with a vector of args. Thanks!
thanks you so much of shadow cljs @thheller , I m pleasantly surprise to get the answer from the greater of shadow cljs it self. Honoured Just one confusion about that how the hot reloading will work, if I serve the output of shadow cljs from my api server? thanks again for the answer.