mount

valerauko 2019-11-04T09:13:06.001600Z

I realize that mount state cannot be copied around before it's started (or it won't get started). Is this intentional behavior, and if so why?

mount.core=> (defstate my-state
  :start (rand-int 50))
#'mount.core/my-state
mount.core=> (def my-map
  {:a my-state
   :b my-state})
#'mount.core/my-map
mount.core=> (start)
{:started ["#'mount.core/my-state"]}
mount.core=> my-map
{:a #object[mount.core.DerefableState 0x6673584c
            {:status :ready,
             :val #object[mount.core.NotStartedState 0x1c4a2946
                          "'#'mount.core/my-state' is not started (to start all the states call mount/start)"]}],
 :b #object[mount.core.DerefableState 0x6673584c
            {:status :ready,
             :val #object[mount.core.NotStartedState 0x1c4a2946
                          "'#'mount.core/my-state' is not started (to start all the states call mount/start)"]}]}

valerauko 2019-11-04T09:13:46.002Z

I'd kinda expect the derefable states in my-map to get started too

Jan K 2019-11-04T11:51:42.004200Z

@vale Mount starts vars, but my-state in the map is not a var, it's just a value. If you put the var #'my-state in your map instead, they will all reference the same state and become started at once.