Reloading re-frame component from repl

118 Views Asked by At

I'm currently trying out ClojureScript, and I'm a bit confused.

I was under the impression that I would be able to reload individual components by evaluating them in the REPL.

I've set up nREPL and nvim conjure. (I've also tried vscode calva)

I can evaluate something like (js/alert "test") and get an alert in the browser, but for example when I have something like:

(defn main-panel []
  (let [name (re-frame/subscribe [::subs/name])]
    [:div
     [:h1
      "Hello from " @name]]))

and change the text, I have to save the file (thereby reloading all the changes, not just the ones I made to that component) to see the changes reflected in the browser.

Was I wrong in thinking that you could use the REPL in this way in clojure script?

1

There are 1 best solutions below

0
On

You can redefine components directly from the REPL, but that won't automatically re-render the component.

In a typical hot-reload workflow the compiled code is first loaded, then a render is triggered. Evaluating a Component at the REPL is basically the loading the code part.

To actually render the component you thus need to call your render function from the REPL as well.

Hot-Reload is the common workflow since the REPL is a bit more manual in that way, but it is certainly doable.