thanks!
Now this is throwing on my test file:
java.lang.ClassNotFoundException: unt.core.DerefableState@41d70dc4
after running this function:
(defn test-start-db []
(-> (mount/only #{Config db/Database})
(mount/swap {Config (read-config "config.test.yml")})
start))
So I just found out that even if I swap the contents of the Config
state, the Database
state will still use the default state of Config
.
boot.user=> (defstate config :start {:answer 42})
#'boot.user/config
boot.user=> (defstate db :start {:connection config})
#'boot.user/db
boot.user=> (defstate some-other-state :start :not-going-to-get-here)
#'boot.user/some-other-state
boot.user=> (defn test-start-db []
#_=> (-> (mount/only #{#'boot.user/config #'boot.user/db})
#_=> (mount/swap {#'boot.user/config {:answer :not-42}})
#_=> mount/start))
#'boot.user/test-start-db
boot.user=> (test-start-db)
{:started ["#'boot.user/config" "#'boot.user/db"]}
boot.user=> config
{:answer :not-42}
boot.user=> db
{:connection {:answer :not-42}}
boot.user=> (require '[mount.tools.graph :as g])
boot.user=> (pprint (g/states-with-deps))
({:name "#'boot.user/config",
:order 1,
:status #{:started},
:deps #{}}
{:name "#'boot.user/db",
:order 2,
:status #{:started},
:deps #{}}
{:name "#'boot.user/some-other-state",
:order 3,
:status #{:stopped},
:deps #{}})