This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-19
Channels
- # adventofcode (52)
- # babashka (47)
- # beginners (13)
- # clojure (36)
- # clojure-belgium (1)
- # clojure-europe (14)
- # clojure-nl (1)
- # clojure-norway (14)
- # clojurescript (2)
- # clojutre (9)
- # cursive (12)
- # datomic (3)
- # deps-new (3)
- # emacs (12)
- # fulcro (5)
- # guix (1)
- # honeysql (7)
- # introduce-yourself (1)
- # jobs (1)
- # kaocha (8)
- # lsp (5)
- # membrane (5)
- # mount (7)
- # nbb (5)
- # nrepl (2)
- # off-topic (60)
- # polylith (9)
- # reclojure (2)
- # reitit (8)
- # ring (17)
- # shadow-cljs (4)
- # spacemacs (31)
- # sql (7)
- # timbre (3)
- # xtdb (15)
Hi! I am experiencing an issue:
After using swap-states
, if I selectively stop states with (mount/stop #'my-state)
and then start again, the swapped state is still being used. (!!)
If I just use (mount/stop)
with no arguments, the swapped state is undone correctly, and original states are started afterwards.
It seems that meta updates done in stop
don't work for state vars, and stop
is not doing the conversion to strings.
There is also a workaround, use (stop (only #'my-state))
. Only will transform vars to strings.
> stop states with (mount/stop #'my-state)
and then start again, the swapped state is still being used. (!!)
if you stop and start a state it would be started, yes.
can you share a REPL’able example?
i.e.
(defstate a …)
(defstate b …)
;;
(mount/stop #'dev/a)
...
(ns mount-test
(:require [mount.core :as mount]))
(mount/defstate my-state
:start (do (println "real start") 1)
:stop (println "real stop"))
(defn swap-with-fake [states]
(mount/swap-states states
{#'my-state {:start (fn [] (do (println "fake start") 2))
:stop (fn [] (println "fake stop"))}}))
(comment
(mount/start (swap-with-fake #'my-state)) ; fake start
(mount/stop #'my-state) ; fake stop
(get @@#'mount/meta-state "#'mount-test/my-state") ; !!! origin still there
(mount/start #'my-state) ; !!! fake start
(mount/stop) ; fake stop
(get @@#'mount/meta-state "#'mount-test/my-state") ; origin is nil
(mount/start #'my-state) ; real start
(mount/stop)) ; real stop
yep, “var vs string” makes sense
the https://github.com/tolitius/mount/commit/2d050e9055418982c29ff284d84b60aa4ad6ceda should be in 0.1.17
thanks for the sample to clarify