Hello all, does anyone here use Figwheel with IntelliJ (Cursive)?
This question is likely more IntelliJ-related than Cursive-related, but I thought this would be a good audience to ask.
When I save a file in IntelliJ, my running Figwheel instance does not do a hot-reload right away. I have to switch my focus to the browser or the Figwheel repl for the hot reload to happen. When saving a file in a different editor, VS Code for example, the hot-reload happens right after saving.
I think this has something to do with the virtual filesystem setup by IntelliJ. Something about saving a file in IntelliJ doesn’t alert other programs like normal. An other clue is when I execute the Reload All From Disk
command inside IntelliJ, the hot-reload happens.
If anyone has a clue it would be a huge step towards front-end nirvana.
Oh you are brilliant. That one question solved it for me.
⌘-S was not bound to anything in IntelliJ. I just assumed it was. It must have auto-saved when I switched the focus off of IntelliJ.
After binding ⌘-S to Save All
, everything works like it should.
Thank you so much. And thank you for Cursive. I really love it.
Great! I’m glad it’s working. And thanks for the kind words, I’m glad you’re liking Cursive!
I have this in my core.cljs
file:
(defn ^:after-load refresh-on-figwheel-reload
[]
(rf/dispatch [:globals/refresh-on-figwheel-reload]))
Do you have something like that?Hey, yup mine is like this
(defn ^:after-load re-render []
(rdom/render [views/app] (dom/$ "app")))
Just re-rendering a reagent component to the dom.
My CLJS files do refresh, but it can take a bit of time to re-compile, plus even after the refresh happens, my UI doesn’t necessarily re-render until it notices a data change. I have the refresh-on-figwheel-reload
event handler set up to increment a value in the app-db, and then in my main page render I have
(fn []
^{:key (str "figwheel-refresh-key-" @[:globals/figwheel-refresh-key])}
[:div.container
;; main page container
])
Hmm, seems like it should work then
Yeah, I think this part is good. But thank you all the same. Your CLJS files refresh without taking focus off of IntelliJ?
You might try the ^{:key ...}
trick, sometimes React does some internal caching that causes it to hold on to old renderings.
Ok, I’ll give that a try.
Generally I can’t see my browser while IntelliJ has the focus, because the browser and the IDE are both full-screen on the same monitor, but I’ve seen CLJS debug messages scroll by in the CLJS REPL, so I’m assuming so.