[docs]: example from dev.clj
This commit is contained in:
parent
5f75399f1f
commit
2379abb778
1 changed files with 21 additions and 9 deletions
30
README.md
30
README.md
|
|
@ -122,6 +122,27 @@ this `app-config`, being top level, can be used in other namespaces, including t
|
||||||
[here](https://github.com/tolitius/mount/blob/master/test/app/nyse.clj)
|
[here](https://github.com/tolitius/mount/blob/master/test/app/nyse.clj)
|
||||||
is an example of a Datomic connection that "depends" on a similar `app-config`.
|
is an example of a Datomic connection that "depends" on a similar `app-config`.
|
||||||
|
|
||||||
|
## The Importance of Being Reloadable
|
||||||
|
|
||||||
|
`mount` has start and stop functions that will walk all the states created with `defstate` and start / stop them
|
||||||
|
accordingly: i.e. will call their `:start` and `:stop` defined functions.
|
||||||
|
|
||||||
|
This can be easily hooked up to [tool.namespace](https://github.com/clojure/tools.namespace), to make the whole
|
||||||
|
application reloadable. Here is a [dev.clj](https://github.com/tolitius/mount/blob/master/dev/dev.clj) as
|
||||||
|
an example, that sums up to:
|
||||||
|
|
||||||
|
```clojure
|
||||||
|
(defn go []
|
||||||
|
(start)
|
||||||
|
:ready)
|
||||||
|
|
||||||
|
(defn reset []
|
||||||
|
(stop)
|
||||||
|
(tn/refresh :after 'dev/go))
|
||||||
|
```
|
||||||
|
|
||||||
|
the `(reset)` is then used in REPL to restart / relaod application state without the need to restart the REPL itself.
|
||||||
|
|
||||||
## Start and Stop Order
|
## Start and Stop Order
|
||||||
|
|
||||||
Since dependencies are "injected" by `require`ing on the namespace level, `mount` trusts Clojure compiler to
|
Since dependencies are "injected" by `require`ing on the namespace level, `mount` trusts Clojure compiler to
|
||||||
|
|
@ -147,15 +168,6 @@ dev=> (reset)
|
||||||
|
|
||||||
You can see examples of start and stop flows in the [example app](https://github.com/tolitius/mount#mount-and-develop).
|
You can see examples of start and stop flows in the [example app](https://github.com/tolitius/mount#mount-and-develop).
|
||||||
|
|
||||||
## The Importance of Being Reloadable
|
|
||||||
|
|
||||||
`mount` has start and stop functions that will walk all the states created with `defstate` and start / stop them
|
|
||||||
accordingly: i.e. will call their `:start` and `:stop` defined functions.
|
|
||||||
|
|
||||||
This can be easily hooked up to [tool.namespace](https://github.com/clojure/tools.namespace), to make the whole
|
|
||||||
application reloadable. Here is a [dev.clj](https://github.com/tolitius/mount/blob/master/dev/dev.clj) as
|
|
||||||
an example.
|
|
||||||
|
|
||||||
## Mount and Develop!
|
## Mount and Develop!
|
||||||
|
|
||||||
`mount` comes with an example [app](https://github.com/tolitius/mount/tree/master/test/app)
|
`mount` comes with an example [app](https://github.com/tolitius/mount/tree/master/test/app)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue