[docs]: about ns state recompilation

This commit is contained in:
Anatoly 2015-12-21 20:42:29 -05:00
parent f8ac28157f
commit 7055cddccd

View file

@ -33,8 +33,9 @@ _**Alan J. Perlis** from [Structure and Interpretation of Computer Programs](htt
- [Suspendable Lifecycle](#suspendable-lifecycle)
- [Plugging into (reset)](#plugging-into-reset)
- [Suspendable Example Application](#suspendable-example-application)
- [Affected States](#affected-states)
- [ClojureScript is Clojure](doc/clojurescript.md#managing-state-in-clojurescript)
- [Affected States](#affected-states)
- [Recompiling Namespaces with Running States](#recompiling-namespaces-with-running-states)
- [Logging](#logging)
- [Mount and Develop!](#mount-and-develop)
- [Running New York Stock Exchange](#running-new-york-stock-exchange)
@ -410,6 +411,23 @@ $ git checkout suspendable
Switched to branch 'suspendable'
```
## Recompiling Namespaces with Running States
At the development time, whenever you "recompile" a namespace, depending on your setup, new versions of its recompiled classes would get reloaded.
In case this namespace included a state reference (i.e. `(defstate ...)`), mount will check if this state is running at the point of recompilation, and if it is, _it will stop it_. Since after the recompilation an old reference to this state will be lost. Mount will also let you know if the state was stopped during recompilation:
<img src="doc/img/ns-recompile.png" width="500px">
The state of course can be started again:
```clojure
dev=> (mount/start #'app.example/nrepl)
INFO app.utils.logging - >> starting.. #'app.example/nrepl
{:started ["#'app.example/nrepl"]}
```
## Affected States
Every time a lifecycle function (start/stop/suspend/resume) is called mount will return all the states that were affected: