Fork me on GitHub
#cursive
<
2020-09-08
>
Harish Tella17:09:11

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.

cfleming00:09:51

That should work. How are you saving the file in IntelliJ?

Harish Tella14:09:08

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.

cfleming19:09:00

Great! I’m glad it’s working. And thanks for the kind words, I’m glad you’re liking Cursive!

manutter5117:09:48

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?

Harish Tella17:09:18

Hey, yup mine is like this

(defn ^:after-load re-render []
  (rdom/render [views/app] (dom/$ "app")))

Harish Tella17:09:47

Just re-rendering a reagent component to the dom.

manutter5117:09:32

Hmm, seems like it should work then

Harish Tella17:09:30

Yeah, I think this part is good. But thank you all the same. Your CLJS files refresh without taking focus off of IntelliJ?

manutter5117:09:44

You might try the ^{:key ...} trick, sometimes React does some internal caching that causes it to hold on to old renderings.

Harish Tella17:09:03

Ok, I’ll give that a try.

manutter5117:09:08

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.

manutter5117:09:55

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
        ])