duct-framework / server.figwheel

Integrant methods for running Figwheel
4 stars 8 forks source link

Live reloading when file changes #1

Closed snichme closed 7 years ago

snichme commented 7 years ago

Current implementation reloads the changes when you (reset) the system but figwheel has the feature that it can reload when you save a file which I think is a very nice way of working.

But the live reload on save doesn't work, either it's broken somewhere or there is a reason for this feature not being active. I would just like to know before digging any deeper into this.

weavejester commented 7 years ago

That is very intentional. By ensuring that only (reset) reloads, we can ensure that the server and client code is always in sync. I also don't think it's a good idea to complect the act of saving files, and the act of reloading them.

In Emacs, I've bound the ⌘R key to the following elisp function:

(defun cider-save-and-refresh ()
  (interactive)
  (save-buffer)
  (call-interactively 'cider-refresh))

This allows me to both save without reloading, and save and then reload. The latest alpha of Duct adds a .dir-locals.el telling Cider how to perform a refresh, so it should work automatically.

Other editors might have similar functionality for calling a Clojure function. Otherwise, you can always write a small watch function. For example, with Hawk:


(hawk/watch! [{:paths ["src" "resources"], :handler (fn [_ _] (reset)))
snichme commented 7 years ago

Thank you for your answer and I agree that reloading by your self is a good idea. I'm using emacs and will absolutely add that function to my config.