From 0e4e5073430899d6ef3749259923fcca1b6b42df Mon Sep 17 00:00:00 2001 From: anatoly Date: Mon, 30 Nov 2015 13:12:44 -0500 Subject: [PATCH] unpounding lifecycle fns --- README.md | 6 +++--- doc/runtime-arguments.md | 4 ++-- doc/uberjar.md | 4 ++-- test/app/app.clj | 4 ++-- test/app/config.clj | 2 +- test/app/nyse.clj | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e1990a1..8e78c8d 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ In case this state needs to be cleaned / destryed between reloads, there is also ```clojure (defstate conn :start create-conn - :stop #(disconnect conn)) + :stop (disconnect conn)) ``` That is pretty much it. But wait, there is more.. this state is _a top level being_, which means it can be simply @@ -146,7 +146,7 @@ There are of course direct dependecies that `mount` respects: (:require [mount.core :refer [defstate]])) (defstate app-config - :start #(load-config "test/resources/config.edn")) + :start (load-config "test/resources/config.edn")) ``` this `app-config`, being top level, can be used in other namespaces, including the ones that create states: @@ -156,7 +156,7 @@ this `app-config`, being top level, can be used in other namespaces, including t (:require [mount.core :refer [defstate]] [app.config :refer [app-config]])) -(defstate conn :start #(create-connection app-config)) +(defstate conn :start (create-connection app-config)) ``` [here](https://github.com/tolitius/mount/blob/master/test/app/nyse.clj) diff --git a/doc/runtime-arguments.md b/doc/runtime-arguments.md index b4d206b..93dbd14 100644 --- a/doc/runtime-arguments.md +++ b/doc/runtime-arguments.md @@ -63,8 +63,8 @@ For the example sake the app reads arguments in two places: * [inside](https://github.com/tolitius/mount/blob/with-args/test/app/nyse.clj#L17) a `defstate` ```clojure -(defstate conn :start #(new-connection (mount/args)) - :stop #(disconnect (mount/args) conn)) +(defstate conn :start (new-connection (mount/args)) + :stop (disconnect (mount/args) conn)) ``` * and from "any" [other place](https://github.com/tolitius/mount/blob/with-args/test/app/config.clj#L8) within a function: diff --git a/doc/uberjar.md b/doc/uberjar.md index 40b2012..25db9f4 100644 --- a/doc/uberjar.md +++ b/doc/uberjar.md @@ -44,8 +44,8 @@ and the reloadable state: (run-jetty {:join? false :port (:port www)}))) -(defstate nyse-app :start #(start-nyse app-config) - :stop #(.stop nyse-app)) ;; it's a "org.eclipse.jetty.server.Server" at this point +(defstate nyse-app :start (start-nyse app-config) + :stop (.stop nyse-app)) ;; it's a "org.eclipse.jetty.server.Server" at this point ``` In order not to block, and being reloadable, the Jetty server is started in the "`:join? false`" mode which starts the server, diff --git a/test/app/app.clj b/test/app/app.clj index 037269f..f529c95 100644 --- a/test/app/app.clj +++ b/test/app/app.clj @@ -11,8 +11,8 @@ (start-server :bind host :port port)) ;; nREPL is just another simple state -(defstate nrepl :start #(start-nrepl (:nrepl app-config)) - :stop #(stop-server nrepl)) +(defstate nrepl :start (start-nrepl (:nrepl app-config)) + :stop (stop-server nrepl)) ;; datomic schema (defn create-schema [conn] diff --git a/test/app/config.clj b/test/app/config.clj index 74303a5..1e18a59 100644 --- a/test/app/config.clj +++ b/test/app/config.clj @@ -10,4 +10,4 @@ edn/read-string)) (defstate app-config - :start #(load-config "test/resources/config.edn")) + :start (load-config "test/resources/config.edn")) diff --git a/test/app/nyse.clj b/test/app/nyse.clj index 7de455f..649dfad 100644 --- a/test/app/nyse.clj +++ b/test/app/nyse.clj @@ -17,5 +17,5 @@ (.release conn) ;; usually it's not released, here just to illustrate the access to connection on (stop) (d/delete-database uri))) -(defstate conn :start #(new-connection app-config) - :stop #(disconnect app-config conn)) +(defstate conn :start (new-connection app-config) + :stop (disconnect app-config conn))