tolitius / mount

managing Clojure and ClojureScript app state since (reset)
Eclipse Public License 1.0
1.22k stars 88 forks source link

`(mount/stop state)` does not `rollback!` the state #124

Open socksy opened 1 year ago

socksy commented 1 year ago

Hi there, I think this is a problem with a missing var-to-str but I can't work out exactly where that should be.

Basically, if you shadow some state, you should expect it to reset when doing mount/stop, but it doesn't.

(require '[mount.core :as mount])
(mount/defstate foo :start :foo)
(mount/start-with-states 
  {#'foo {:start (constantly :bar)
          ;; to get it to even be able to be stopped when given to (mount/stop)
          :stop (constantly nil)}})
(println foo) ;; => :bar

;; unexpected behaviour
(mount/stop #'foo)
(mount/start)
(println foo) ;; => :bar

;; workaround
(mount/stop "#'user/foo")
(mount/start)
(println foo) ;; => :foo