mergin restart listener changes

This commit is contained in:
anatoly 2016-11-02 19:21:23 -04:00
commit a397ae5cc5
3 changed files with 11 additions and 9 deletions

View file

@ -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.
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

View file

@ -1,4 +1,4 @@
(def +version+ "0.1.10")
(def +version+ "0.1.11-SNAPSHOT")
(set-env!
:source-paths #{"src"}

View file

@ -312,16 +312,18 @@
(add-watcher [_ ks state]
(doseq [k ks]
(swap! watchers update k #(conj % state))))
(swap! watchers update k (fn [v]
(-> (conj v state) vec)))))
(on-change [_ k]
(let [states (@watchers k)]
(apply stop states)
(apply start states))))
(on-change [_ ks]
(doseq [k ks]
(when-let [states (seq (@watchers k))]
(apply stop states)
(apply start states)))))
(defn restart-listner
(defn restart-listener
([]
(restart-listner {}))
(restart-listener {}))
([watchers]
(RestartListener. (atom watchers))))