This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-22
Channels
- # announcements (2)
- # architecture (33)
- # babashka (4)
- # beginners (445)
- # bristol-clojurians (10)
- # calva (23)
- # cider (43)
- # clj-kondo (36)
- # cljs-dev (13)
- # cljsrn (20)
- # clojure (136)
- # clojure-argentina (8)
- # clojure-dev (1)
- # clojure-europe (18)
- # clojure-germany (1)
- # clojure-italy (5)
- # clojure-nl (45)
- # clojure-spec (66)
- # clojure-uk (29)
- # clojurescript (69)
- # conjure (157)
- # cursive (2)
- # datomic (216)
- # emacs (10)
- # exercism (4)
- # figwheel-main (8)
- # fulcro (30)
- # graphql (21)
- # hoplon (5)
- # kaocha (7)
- # leiningen (3)
- # luminus (4)
- # music (1)
- # off-topic (24)
- # pathom (10)
- # re-frame (19)
- # reagent (11)
- # reitit (16)
- # remote-jobs (1)
- # ring-swagger (5)
- # rum (7)
- # shadow-cljs (125)
- # spacemacs (8)
- # sql (9)
- # tools-deps (12)
Is anyone using ClojureScript to target NodeJS apps? I don’t know Java so I’m more comfortable using ClojureScript for frontend and Node backend?
it's definitely been done - using clojure is less complex than cljs as cljs is a clojure program
there's self hosting cljs but it doesn't have the features you likely want
Is there a way to specify npm script commands from a deps alias? Lets say I want to run a watcher to transpile something not related to cljs through npm upon running an alias.
Could someone offer some insight as to how I can get vim-fireplace
to play nice with cljs
files?
I've tried starting a nrepl as follows using piggieback, but even though Fireplace connects to it, it complains about cljs
. (not as seamless as the docs for fireplace
would suggest, sadly). Putting the below as an alias in my ~/.clojure/deps.edn
,
:cider-cljs {:extra-deps {org.clojure/clojure {:mvn/version "1.10.1"}
org.clojure/clojurescript {:mvn/version "1.10.339"}
cider/cider-nrepl {:mvn/version "0.24.0"}
cider/piggieback {:mvn/version "0.4.1"}}
:main-opts ["-m" "nrepl.cmdline" "--middleware"
"[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}
and calling clj -A:cider-cljs
, starts the nrepl. clj
and cljc
files are fine, but not cljs
.@noelmartin I've done this a couple of times. Small servers using node's express web server and Postgres.
Would you recommend it? What were the challenges? What were the good/bad things, if you don’t mind me asking?
No problem! The challenges were the same as with nodejs servers in general - I usually find catching and handling errors in a robust way that doesn't break the server, to be a challenge. So I try to keep my backend server extremely lean, basically an authenticated data store.
I would recommend it if you know and love the node VM & it's library ecosysstem. I would recommend using shadow-cljs to build both your client and server in a single monolithic repository.
Getting live reloading of express routes working was also a bit tricky.
(defn reload! []
(let [router app._router]
(when router
(print (str "Deleting " (-> app .-_router .-stack .-length) " routes"))
(set! app._router nil)))
(setup-routes app pg-pool)
(println "Fresh routes loaded."))
As you can see I had to delete all routes and re-create them each time the code was hot swapped.Thank you. I would look into this.
No worries, hit me up if you need any more info.
⚓ Does cljs have an http library that supports parallel requests and caching? I'm currently building a wrapper on top of @roman01la's @r0man's cljs-http, but wondering if something exists already..
Sorry, fixed
Anyone knows how to fix https://nvd.nist.gov/vuln/detail/CVE-2020-8910 :thinking_face: ? NVD is reporting an issue with the bundled closure compiler, but no upstream fix seems available
Wrote a short guide on ClojureScript REPL workflow, feel free to add yours in comments https://gist.github.com/roman01la/b939e4f2341fc2f931e34a941aba4e15
Thanks for this writeup. I always found the idea of saved-file reloading somewhat bizarre, and a step back from the times of Common Lisp. I always preferred to eval single forms, or load an entire file with C-c C-k.
I suspect many people who are praising auto-file-reloading have never used single-form evaluation from the editor.
I guess this workflow requires a habit to always reload your changes immediately, otherwise it's easy to miss something
I still have a suspicion that whole-file reloading became popular mostly because of people who haven't seen anything better. And it's true that it is a great improvement over re-loading the entire project.
What's the idiomatic way to get the properties of a hiccup or reagent object? Say I have a [:div {:on-click foo}] and I want to access its on-click property?
maybe just as inelegant but what about (get-in obj [1 :on-click])
How do I quote the return value of a function in ClojureScript? My function is returning some Hiccup data - including fns - but I want to print the pure data:
{:tabs
[["1" [user/padded "One"]]
["4" [user/padded "Four"]]
["3" [user/padded "Three"]]
["2" [user/padded "Two"]]],
:i 2}
and not the default:
{:tabs
[["1" [#object[user$padded] "One"]]
["4" [#object[user$padded] "Four"]]
["3" [#object[user$padded] "Three"]]
["2" [#object[user$padded] "Two"]]],
:i 2}
I thought about writing a function that recurs through a data structure, finding the fns and converting them, but I’m sure there is a simpler and more generic way to accomplish the same thing.I got something like #object[object Object] when use (GET http://aRestfulUrl). Can you help me how to convert the json to CLJS object? Thanks.
@simongray you can't quote functions, recursively handing them is probably going to be more practical
Add :keywordize-keys true, to convert key values to keywords
no, they are two different functions
two different memory blocks let's say
for my purpose, they should be equal. How do I test that kind of equality? Say Dom-behavior equality?
put it into a var
then (= f f)
will be true
(let [f #(js/alert "hi")]
(= f f))
those are usual JavaScript functions, so equality semantics is the same, how is that you are expecting them to be equal?
even?
and #(zero? (mod % 2))
are equivalent but convincing a computer of that is turing prize quality work
How can I add a js file in my shadow build process? It's a postcss.config.js file in my root directory
Hello Clojurians, I have a quick question regarding Reagent/Hiccup syntax. I was working through a basic Reagent + Tailwindcss example (https://github.com/mrmcc3/tailwind-cljs-example/tree/master/shadow-cljs) and noticed in the app.cljs file the author used this notation to render a vector of classes without string notation: `[:div {:class '[max-w-3x mx-auto pt-12]}`. I messed around with it and found that it this notation (`'[max-w-3x mx-auto]` ) is equivalent to just writing the string: `"max-w-3x mx-auto"` . Is this standard Clojure syntactic sugar or some Hiccup magic? I can’t seem to find any documentation on this use of the single quote as the docs (https://clojuredocs.org/clojure.core/quote or https://clojure.org/guides/weird_characters#_quote) appear to be talking about delayed eval. Thanks for the help everyone 🙂
what '
does is prevent evaluation, in this context it creates a vector of symbols. Hiccup then has a special action for a vector of symbols
Also is Reagent helping you - it accepts strings and seq of classes , including a plain vector: ["max-w-3x" "pt-12"]
which means you can do stuff like [(when active? "text-bold") "text-red-600"]
Awesome! Thanks for clearing that up. Is there a style preference to explicitly using strings (`["class-1" "class-2"]`) vs what this author did of just writing them as symbols (`'[class-1 class-2]`)?
I only dabble in clojurescript but I've seen strings used for classes in most examples, I don't recall seeing quoted lists - the only convenience is that you don't have to use quotes I suppose. Maybe others can weigh in
How do I use reframe in the repl? In my project files subscribe and dispatch works, but in the connected shadow-cljs repl, the dispatches and the subscribes are all returning nil
I've created a macro:
(defmacro defelem [name element]
`(ws/defcard ~name
(ct.react/react-card
(r/as-element
~element
)
)
)
)
But when I run it in the repl, I get the error TypeError: Cannot set property 'defelem' of undefined. Why is this and what's the fix?in order to get help, you should always provide two pieces of info:
• what you’re trying to do
• what you’ve tried
in this case, we don’t know what file you’ve created defelem
in, how you’re trying to use defelem
, so the error might be that, or it might be in your macro, we don’t know. there’s a lot of context missing, so we can’t tell you why it is or how to fix it
I'm using #workspaces which has a defcard macro for creating cards, which is great, and so I might do:
(ws/defcard tw-card
(ct.react/react-card
(r/as-element
[:div "hi"]
)
)
)
to show a div with "hi" in it. However, the first three lines almost never change for me, so I would like to create a macro that lets me do: (defelem tw-card [:div "hi"]).
This was my attempt:
(defmacro defelem [name element]
`(ws/defcard ~name
(ct.react/react-card
(r/as-element
~element
)
)
)
)
In my shadow project itself, when I use the macro like so: (defelem mycard [:div "hi"]) I get a warning that
(defelem mycard [:div "hi"])
----------------^---------------------------------------------------------------
Use of undeclared Var vendo.workspaces.cards/mycarddid you follow https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html? macros are written and clojure and need to follow certain rules to be available properly
Has anyone used Firebase for backend? Is it useful enough to warrant not writing a server in clojure? If you have, what did and what did you not like about it?