This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-21
Channels
- # alda (1)
- # bangalore-clj (1)
- # beginners (7)
- # boot (88)
- # carry (2)
- # cider (8)
- # cljs-dev (60)
- # cljsjs (2)
- # cljsrn (45)
- # clojure (255)
- # clojure-belgium (5)
- # clojure-boston (1)
- # clojure-dusseldorf (3)
- # clojure-greece (49)
- # clojure-italy (10)
- # clojure-russia (30)
- # clojure-spec (78)
- # clojure-uk (11)
- # clojurebridge (1)
- # clojurescript (80)
- # cursive (14)
- # datomic (33)
- # defnpodcast (4)
- # devcards (2)
- # dirac (15)
- # editors (23)
- # emacs (5)
- # events (11)
- # funcool (1)
- # hoplon (1)
- # juxt (1)
- # luminus (2)
- # mount (7)
- # off-topic (15)
- # om (152)
- # om-next (2)
- # onyx (17)
- # parinfer (1)
- # proton (38)
- # re-frame (35)
- # reagent (110)
- # rum (3)
- # spacemacs (3)
- # specter (51)
- # test-check (2)
- # testing (5)
- # untangled (234)
i am working a project where a state is dependent on other states. ie: conn1 (conn2 conn1 config) (conn3 conn1 conn2) how do i express this in mount?
@dhruv1: do you mean that conn1
should be started before conn2
, and "`conn1` and conn2
" should be started before conn3
?
if you have states defined as:
(defstat config :start ...)
(defstate conn1 :start (new-conn config)
(defstate conn2 :start (new-conn conn1 config))
(defstate conn3 :start (new-conn conn1 conn2))
internally mount will assign an :order
to each state as they were compiled. and since conn2
can't be compiled without compiling conn1
and config
, it will be "ordered"/started after them.something like this https://github.com/stuartsierra/component#systems
ok i think this reflects what i’m talking about https://github.com/tolitius/mount/blob/master/README.md#start-and-stop-order
this is interesting.
I defined a var with a defstate
but made a mistake the first time around.
;; not the same mistake but it will help elaborate what I’m trying to explain
(def conn1-atom (atom nil))
(defstate conn
:start (reset! conn1-atom :started)
:stop (reset! :started conn1-atom)) ;; there is a mistake in :stop.
(mount/start) ;; this works fine.
(mount/stop) ;; produces the error.
ClassCastException clojure.lang.Keyword cannot be cast to clojure.lang.IAtom clojure.core/reset! (core.clj:2273)
;; trying to re-define conn
but keep running into the same error.
(defstate conn
:start (reset! conn1-atom :started)
:stop (reset! :started conn1-atom))