Search code examples
dynamicclojure

How to automatically reload Clojure code?


How to automatically reload Clojure code?

I have watched the presentation. And in there they use some hot swap Clojure technology that reloads code whenever changes are made into source files. I can run the code, but I can not observe the effect of auto reload. How is it possible to reload the code?

the source code.


Solution

  • There are many ways to reload code, depending on the situation:

    • Emacs/CIDER shortcuts to reload a file. Probably Rich is doing something similar. Also see this: How to reload a clojure file in REPL
    • watch files and reload the code (figwheel for frontend development does that, test plugins as well as CIDER shortcuts specifically for running tests, boot has a watch task...)
    • a middleware for the web server you use (ring for example has ring.middleware.reload/wrap-reload for this, pedestal comes with one as well, other webservers like yada play well with component)
    • a component workflow works also, there is an example of an auto-reloadable system with holy-grail