mount

pablore 2018-11-13T12:05:28.057100Z

thanks!

pablore 2018-11-13T12:20:47.057600Z

Now this is throwing on my test file: java.lang.ClassNotFoundException: unt.core.DerefableState@41d70dc4

pablore 2018-11-13T12:21:14.058Z

after running this function:

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

pablore 2018-11-13T14:09:24.059200Z

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.

tolitius 2018-11-13T19:31:51.059500Z

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