Fork me on GitHub
#clojurescript
<
2020-12-10
>
Timofey Sitnikov12:12:01

Good Morning Clojurians, If I start shadow-cljs like so:

p1~> npx shadow-cljs server
shadow-cljs - config: /home/sporty/clojure/fulcro/app1/shadow-cljs.edn
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.11.8 running at 
shadow-cljs - nREPL server started on port 9000
How do you start REPL to the nREPL on the port 9000?

thheller12:12:53

you use your editor to connect?

Timofey Sitnikov13:12:29

I do connect with the editor, but it does not give me just a REPL.

Timofey Sitnikov13:12:20

I use vim-iced, but I would like to have just a regular terminal REPL to quickly explore.

thheller14:12:26

just use shadow-cljs node-repl or shadow-cljs browser-repl then

borkdude13:12:35

@timofey.sitnikov You can use lein repl :connect to connect to an nREPL server. I'm not sure if that works for ClojureScript, but why not, it's just nREPL after all?

Timofey Sitnikov13:12:14

Thank you @borkdude, I did some more research on your recommendation, and it led me to: https://nrepl.org/nrepl/usage/clients.html#command-line-clients. I try to avoid using lein.

borkdude13:12:00

Well, you don't have to use lein as a dep manager, but it works just fine as an nREPL client. it has REPL-y built in. Up to you. Good luck.

borkdude13:12:46

@timofey.sitnikov

$ clojure -Sdeps '{:deps {reply/reply {:mvn/version "0.4.4"}}}' -M -m reply.main --attach localhost:43851
seems to work fine for my current JVM nREPL :)

Timofey Sitnikov13:12:44

@borkdude, one more question for you, what is the best place to read how to resolve the fulcro defsc Unresolved Symbol error by clj-kondo? I followed the setup instructions, created the .clj-kondo and ran linting on the namespace to create the cache but still get that error.

borkdude13:12:29

@timofey.sitnikov the config project has a config for specifically that one: https://github.com/clj-kondo/config/blob/master/resources/clj-kondo.exports/clj-kondo/fulcro/config.edn There's work going on in #clj-kondo to come up with more advanced config to cover more of fulcro.

Timofey Sitnikov14:12:13

Perfect, thank you ...

joelv14:12:33

Having issues with doing advanced compilation with trying wrap an npm dependency with webpack bundler.

Bundling command failed
[webpack-cli] Compilation finished
assets by status 1.16 MiB [cached] 1 asset
runtime modules 889 bytes 4 modules
cacheable modules 1.18 MiB
  ./target/public/cljs/dev/main.js 1.08 MiB [built] [code generated]
  ./node_modules/@auth0/auth0-spa-js/dist/auth0-spa-js.production.esm.js 101 KiB [built] [code generated]

ERROR in ./target/public/cljs/dev/main.js 57:95-111
Module not found: Error: Can't resolve 'react' in '/Users/jvillahermosa/code/clj/self-service-ui/target/public/cljs/dev'

ERROR in ./target/public/cljs/dev/main.js 983:791-831
Module not found: Error: Can't resolve 'xmlhttprequest' in '/Users/jvillahermosa/code/clj/self-service-ui/target/public/cljs/dev'

webpack 5.9.0 compiled with 2 errors in 12628 ms

fsd23:12:58

Hello Everyone, I am new to Clojure (I am js Dev), this question might sound silly. I want to change the value of a boolean variable to the opposite of its value. For example, if the value of a variable is true I want to change to false, vice versa. Since the only way to change the variable value is to use the atom and that’s what I used. I don’t know why I am getting this error.

Example: 
cljs.user=> (def isclicked (atom true))
#'cljs.user/isclicked
cljs.user=> @isclicked
true
cljs.user=> (swap! isclicked (not isclicked))
ERROR - db.call is not a function

dpsutton23:12:50

(swap! is-clicked not)

fsd00:12:34

@U11BV7MTK thanks for your reply Ah I see, in Javascript I can just

let isclicked = false
false
isclicked = !isclicked
true
isclicked
true
isclicked = !isclicked
false
isclicked
false
Is there anyway I can change the value of a boolean variable to the opposite of its value like how I did it in JavaScript?

dpsutton00:12:18

yes. in your example you can do (swap! isclicked not)

dpsutton00:12:18

user=> (def clicked? (atom false))
#'user/clicked?
user=> (swap! clicked? not)
true
user=> @clicked?
true
user=>

dpsutton00:12:18

if you just want to set the value of an atom irrespective of its current value then (reset! clicked? true) or (reset! clicked? (not @clicked?)) . note this one where you are setting its value based on the current value of the atom is precisely what (swap! clicked? not) is doing except its changing it atomically without race conditions

fsd00:12:48

ohhhhh that makes sense, thanks so much @U11BV7MTK time and help

dpsutton23:12:24

swap takes an atom and a function to run on the value. (not isclicked) would return false as isclicked is an atom and therefore truthy (not false or nil) and negating that returns false. (swap! isclicked false) will call false with the argument of true (the current value of the isclicked atom) and blow up