Fork me on GitHub
#mount
<
2018-11-13
>
pablore12:11:47

Now this is throwing on my test file: java.lang.ClassNotFoundException: [email protected]

pablore12:11:14

after running this function:

(defn test-start-db []
  (-> (mount/only #{Config db/Database})
      (mount/swap {Config (read-config "config.test.yml")})
      start))

pablore14:11:24

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.

tolitius19:11:51

@pablore

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 #{}})