mergin restart listener changes
This commit is contained in:
commit
a397ae5cc5
3 changed files with 11 additions and 9 deletions
|
|
@ -581,7 +581,7 @@ Since mount is a _library_ it should _not_ bring any dependencies unless its fun
|
||||||
|
|
||||||
> But I still these logging statements in the examples.
|
> But I still these logging statements in the examples.
|
||||||
|
|
||||||
The way this is done is via an excellent [robert hooke](https://github.com/technomancy/robert-hooke/). Example applications live in `test`, so does the [utility](https://github.com/tolitius/mount/blob/75d7cdc610ce38623d4d3aea1da3170d1c9a3b4b/test/app/utils/logging.clj#L44) that adds logging to all the mount's lifecycle functions on start in [dev.clj](https://github.com/tolitius/mount/blob/75d7cdc610ce38623d4d3aea1da3170d1c9a3b4b/dev/dev.clj#L21).
|
The way this is done is via an excellent [robert hooke](https://github.com/technomancy/robert-hooke/). Example applications live in `test`, so does the [utility](test/clj/tapp/utils/logging.clj#L42) that adds logging to all the mount's lifecycle functions on start in [dev.clj](https://github.com/tolitius/mount/blob/75d7cdc610ce38623d4d3aea1da3170d1c9a3b4b/dev/dev.clj#L21).
|
||||||
|
|
||||||
## Clojure Version
|
## Clojure Version
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
(def +version+ "0.1.10")
|
(def +version+ "0.1.11-SNAPSHOT")
|
||||||
|
|
||||||
(set-env!
|
(set-env!
|
||||||
:source-paths #{"src"}
|
:source-paths #{"src"}
|
||||||
|
|
|
||||||
|
|
@ -312,16 +312,18 @@
|
||||||
|
|
||||||
(add-watcher [_ ks state]
|
(add-watcher [_ ks state]
|
||||||
(doseq [k ks]
|
(doseq [k ks]
|
||||||
(swap! watchers update k #(conj % state))))
|
(swap! watchers update k (fn [v]
|
||||||
|
(-> (conj v state) vec)))))
|
||||||
|
|
||||||
(on-change [_ k]
|
(on-change [_ ks]
|
||||||
(let [states (@watchers k)]
|
(doseq [k ks]
|
||||||
|
(when-let [states (seq (@watchers k))]
|
||||||
(apply stop states)
|
(apply stop states)
|
||||||
(apply start states))))
|
(apply start states)))))
|
||||||
|
|
||||||
(defn restart-listner
|
(defn restart-listener
|
||||||
([]
|
([]
|
||||||
(restart-listner {}))
|
(restart-listener {}))
|
||||||
([watchers]
|
([watchers]
|
||||||
(RestartListener. (atom watchers))))
|
(RestartListener. (atom watchers))))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue