Closed mping closed 5 years ago
mount does not prevent any metadata being added to a state:
=> (defstate answer :start 42)
#'boot.user/answer
boot.user=> (binding [answer 34] (inc answer))
java.lang.IllegalStateException: Can't dynamically bind non-dynamic var: boot.user/answer
boot.user=> (defstate ^:dynamic answer :start 42)
#'boot.user/answer
boot.user=> (binding [answer 34] (inc answer))
35
boot.user=> answer
#object[mount.core.DerefableState 0x29da1877 {:status :pending, :val nil}]
boot.user=> (meta #'answer)
{:dynamic true, :line 1, :column 1, :name answer, ...}
boot.user=> (defstate ^{:on-reload :noop :dynamic true} foo :start :bar)
boot.user=> (meta #'foo)
{:on-reload :noop, :dynamic true, :line 1, :column 1, :name foo, ...}
I could swear I did the same test. Will confirm when on the laptop. Sorry for the noise.
sure, no worries
Besides
:on-reload
,defstate
should pass down any other meta to the var definition (such as:dynamic
)