Hey, I have a slightly hypothetical question: I'm writing some shared library code, and in the ideal case I want it to work either with or without mount. Is there an easy way from my code determine if it's running inside mount? (Eg, whether (mount/start)
has been called or not)
@timgilbert: will this work for you?
dev=> (mount/running-states)
nil
dev=> (mount/start)
...
{:started ["#'app.conf/config" "#'app.db/conn" "#'app.www/nyse-app" "#'app.example/nrepl"]}
dev=>
dev=> (mount/running-states)
("#'app.conf/config" "#'app.db/conn" "#'app.www/nyse-app" "#'app.example/nrepl")
dev=> (mount/stop "#'app.db/conn")
INFO app.db - disconnecting from datomic:<mem://mount>
{:stopped ["#'app.db/conn"]}
dev=> (mount/running-states)
("#'app.conf/config" "#'app.www/nyse-app" "#'app.example/nrepl")
if yes, I put in in 0.1.11-SNAPSHOT
Oh, that's great, thanks!
I'll mess around with it and let you know. I'm still in the hammock phase of development right now
sure, let me know. I think running-states
is good to have regardless, so thanks for bringing it up. you could also get it via graph, e.g.:
dev=> (require '[mount.tools.graph :as graph])
nil
dev=> (map :name (filter (comp :started :status) (graph/states-with-deps)))
()
dev=> (mount/start)
...
{:started ["#'app.conf/config" "#'app.db/conn" "#'app.www/nyse-app" "#'app.example/nrepl"]}
dev=> (map :name (filter (comp :started :status) (graph/states-with-deps)))
("#'app.conf/config" "#'app.db/conn" "#'app.www/nyse-app" "#'app.example/nrepl")
but (running-states)
is a bit simpler
i.e. (graph/states-with-deps)
returns: https://github.com/tolitius/mount/issues/12#issuecomment-167150505