Hello There,
I have a quick question, I am new in clojure
How do I use png file in cljs?
I have a shadow cljs application
for example "./icons/marker.png
I’ve tried using this but it’s not loading
how are you embedding it? this is not a CLJS question really, more HTML specific. if you use ./
in the path it'll be relative to the page you are on. you need to make sure the path is correct.
This has nothing to do with shadow-cljs, try #beginners or #clojurescript But generally, you need to start a webserver and serve that file on the webserver you started shadow-cljs has https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http, but you don't want to use that for your final app...
Hi, how can I name the file something other than main.js?
this caught me too, the key in the map decides
Aha
thank you @ashnur
Hi there. Is it possible to invalidate the node_modules
cache without restarting npx shadow-cljs watch app
? Any option?
invalidate why? I mean what do you expect that to achieve?
I put some console.log
on npm package for debugging.
you can touch node_modules/that-package/package.json
to trigger a recompile
I don't have any output, so I supposed that's because Shadow cache.
Oh perfect, thx!
yeah I removed individual file watching for node_modules
files because some projects used like 5000 files from there and that was causing some performance issues
but it still watches package.json
files in cause you npm install
stuff or so
touching the package.json will invalidate the entire package
Yeah I understand, very good reason performance wise. Thanks Thomas.
Is there a reason I should defonce
my app-db
in a re-frame project from a hot-reload perspective?
yes, without it the hot-reload will just replace it with a new atom when you modify the file
defonce is needed if you want to keep your state
The state seems to be kept in the re-frame.db/app-db ratom. I notice no difference when I use def
on my app-db. hot reload seems to work the same.
then I don't understand your question. when using re-frame you don't have your own app-db?
I am asking because I am going to present ClojureScript app development on a meetup Wednesday. And I had sort of planned to mention defonce as a protector of the app-db, but when I tested it I noticed that that part of the demo doesn’t seem to hold. Looking in re-frame.db then, it’s app-db is also just (def app-db (ratom {}))
. I just want to understand a bit better how it really works. Even if I realize I should stay away from the subject during the demo. 😃
well you don't modify the re-frame.db
namespace so it is never reloaded and never has this issue
Ah. Thanks!
if you have this is your main namespaces that is constantly getting reloaded you will lose your state every time without defonce 😉
Yeah, I can totally get it to happen with a local atom and such. Which added to my confusion.