open-bounty/env/dev/clj/user.clj
Oliver Martell 985f723c7c [Fix #306] Add support for reloading code
This adds `clojure.tools.namespace` to be able to reload code. It's a better
alternative to `reload-all` as outlined
[here](https://github.com/clojure/tools.namespace#reloading-code-motivation)
and [here](https://github.com/tolitius/mount#the-importance-of-being-reloadable).

If you run:
- `refresh` will reload all changed namespaces with their latest definition.
- `reset` will stop the current system first, then refresh, and restart the
dependencies.
2018-02-21 13:25:36 +01:00

35 lines
810 B
Clojure

(ns user
(:require [mount.core :as mount]
[commiteth.figwheel :refer [start-fw stop-fw cljs]]
[clojure.tools.namespace.repl :as repl]))
(repl/set-refresh-dirs "src" "dev" "test")
(defn start
"Start all the application components"
[]
(require 'commiteth.core)
(mount/start-without (ns-resolve 'commiteth.core 'repl-server)))
(defn stop
"Stop all the application components"
[]
(require 'commiteth.core)
(mount/stop-except (ns-resolve 'commiteth.core 'repl-server)))
(defn refresh
"Reload the latest namespace definitions"
[]
(repl/refresh))
(defn reset
"Restart application after refreshing namespace definitions"
[]
(stop)
(repl/refresh :after 'user/start))
(defn restart []
"Restart without refreshing namespace definitions"
(stop)
(start))