This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-13
Channels
- # announcements (4)
- # babashka (1)
- # beginners (124)
- # calva (5)
- # cider (3)
- # clara (3)
- # clerk (5)
- # clj-commons (14)
- # cljdoc (12)
- # cljs-dev (14)
- # clojure (43)
- # clojure-austin (23)
- # clojure-europe (55)
- # clojure-nl (1)
- # clojure-norway (11)
- # clojure-uk (2)
- # clojurescript (34)
- # conjure (1)
- # cursive (1)
- # data-science (28)
- # datomic (3)
- # fulcro (20)
- # gratitude (2)
- # hyperfiddle (6)
- # introduce-yourself (1)
- # jobs (5)
- # lsp (56)
- # malli (5)
- # membrane (7)
- # mount (5)
- # off-topic (16)
- # polylith (39)
- # portal (38)
- # practicalli (1)
- # rdf (1)
- # re-frame (8)
- # releases (8)
- # remote-jobs (4)
- # shadow-cljs (49)
- # sql (1)
- # xtdb (36)
Hello! Is mount/start
idempotent? I start the system as part of connecting to the repl. When reconnecting the repl I want to avoid starting the app, but I don't really know if it is an initial connect or a reconnect. I could make do with some way to tell if the system is running, but I don't immediately see a way to do that. (I'm a complete mount noob.)
@pez
> I could make do with some way to tell if the system is running
you can use (mount/running-states)
to see what is currently running:
dev=> (defstate db-connection :start (println "connecting")
:stop (println "disconnecting..."))
#'dev/db-connection
dev=> (mount/running-states)
#{}
dev=> (mount/start #'dev/db-connection)
connecting
{:started ["#'dev/db-connection"]}
dev=> (mount/running-states)
#{"#'dev/db-connection"}
> When reconnecting the repl I want to avoid starting the app
if the states are already started, mount won’t be starting them again
dev=> (defstate db-connection :start (println "connecting")
:stop (println "disconnecting..."))
#'dev/db-connection
dev=> (mount/start #'dev/db-connection)
connecting
{:started ["#'dev/db-connection"]}
dev=> (mount/start #'dev/db-connection)
{:started []} ;; was not started again, since it is already started
* not sure if needed in this case, but just another piece of intel
if you recompile a namespace that contains defstate
, mount would restart it
but, it could be optional by using :on-reload [value]
meta (https://github.com/tolitius/mount#recompiling-namespaces-with-running-states)