#83: [docs] add doc string
This commit is contained in:
parent
b3f3f49d64
commit
562340f4dc
2 changed files with 20 additions and 3 deletions
16
README.md
16
README.md
|
|
@ -124,6 +124,22 @@ For example let's say an `app` needs a connection above. No problem:
|
||||||
|
|
||||||
where `above` is an arbitrary namespace that defines the above state / connection.
|
where `above` is an arbitrary namespace that defines the above state / connection.
|
||||||
|
|
||||||
|
### Documentation String
|
||||||
|
|
||||||
|
As in any definition (i.e. `def`, `defn`) a documentation string can be added to better describe a state:
|
||||||
|
|
||||||
|
```clojure
|
||||||
|
(defstate answer
|
||||||
|
"answer to the ultimate question of life universe and everything"
|
||||||
|
:start (+ 1 41))
|
||||||
|
```
|
||||||
|
```clojure
|
||||||
|
(doc answer)
|
||||||
|
-------------------------
|
||||||
|
dev/answer
|
||||||
|
answer to the ultimate question of life universe and everything
|
||||||
|
```
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
If the whole app is one big application context (or `system`), cross dependencies with a solid dependency graph
|
If the whole app is one big application context (or `system`), cross dependencies with a solid dependency graph
|
||||||
|
|
|
||||||
|
|
@ -164,9 +164,10 @@
|
||||||
(deftime
|
(deftime
|
||||||
|
|
||||||
(defmacro defstate
|
(defmacro defstate
|
||||||
"Defines a state. Restarts on recompilation.
|
"defines a state (a.k.a. a stateful component).
|
||||||
Pass ^{:on-reload :noop} to prevent auto-restart
|
restarts on recompilation.
|
||||||
on ns recompilation, or :stop to stop on recompilation."
|
pass ^{:on-reload :noop} to prevent auto-restart on ns recompilation,
|
||||||
|
or ^{:on-reload :stop} to stop on recompilation."
|
||||||
[state & body]
|
[state & body]
|
||||||
(let [[state params] (mount.tools.macro/name-with-attributes state body)
|
(let [[state params] (mount.tools.macro/name-with-attributes state body)
|
||||||
{:keys [start stop] :as lifecycle} (apply hash-map params)
|
{:keys [start stop] :as lifecycle} (apply hash-map params)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue