Fork me on GitHub
#mount
<
2020-03-12
>
simonkatz17:03:32

Hi. I'm new here — just joined a company that's using mount. :-) What's the recommended way to check whether a state is running? I think I want something like (defstate foo :start ... :stop (when <running> ...))

tolitius20:03:17

in order to checks which states are running:

(mount/running-states)
will return a set of states that are currently running but to your specific example, foo is available as a known reference "at a :stop function", so depending on what type foo is, you can do something like that:
(defstate server :start (start-server)
                 :stop (when server (.stop server)))

simonkatz14:03:04

I think I’m confused by the different values I’ve seen for the state. Sometimes I see an object that says “Pending”, sometimes an object that says “Not Started” (IIRC), and sometimes a value that I can apply my stop function to. I really need to learn about the lifecycle of states, I guess. For now, I’ve simply wrapped the start and stop forms in a (when <do-we-want-to-run-this-state> …

simonkatz14:03:04

I think I’m confused by the different values I’ve seen for the state. Sometimes I see an object that says “Pending”, sometimes an object that says “Not Started” (IIRC), and sometimes a value that I can apply my stop function to. I really need to learn about the lifecycle of states, I guess. For now, I’ve simply wrapped the start and stop forms in a (when <do-we-want-to-run-this-state> …