[#21]: examples of "fn" vs. "(fn)" for a lifecycle fns

This commit is contained in:
anatoly 2015-12-01 08:46:43 -05:00
parent bf5294edb7
commit 7f720403ea
2 changed files with 15 additions and 1 deletions

View file

@ -175,17 +175,22 @@ Besides scalar values, lifecycle functions can take anonymous functions, partial
(defn- pf [n]
(+ 41 n))
(defn fna []
42)
(defstate scalar :start 42)
(defstate fun :start #(inc 41))
(defstate with-fun :start (inc 41))
(defstate with-partial :start (partial g 41))
(defstate f-in-f :start (f 41))
(defstate f-no-args-value :start (fna))
(defstate f-no-args :start fna)
(defstate f-args :start g)
(defstate f-value :start (g 41 1))
(defstate private-f :start pf)
```
Check out [fun-with-values-test](https://github.com/tolitius/mount/blob/958d7e345c9ad0983d30d44af9d852fe8d2d0bcc/test/check/fun_with_values_test.clj) for more details.
Check out [fun-with-values-test](https://github.com/tolitius/mount/blob/0.1.5/test/check/fun_with_values_test.clj) for more details.
## The Importance of Being Reloadable

View file

@ -12,11 +12,16 @@
(defn- pf [n]
(+ 41 n))
(defn fna []
42)
(defstate scalar :start 42)
(defstate fun :start #(inc 41))
(defstate with-fun :start (inc 41))
(defstate with-partial :start (partial g 41))
(defstate f-in-f :start (f 41))
(defstate f-no-args-value :start (fna))
(defstate f-no-args :start fna)
(defstate f-args :start g)
(defstate f-value :start (g 41 1))
(defstate private-f :start pf)
@ -28,6 +33,8 @@
#'check.fun-with-values-test/with-partial
#'check.fun-with-values-test/f-in-f
#'check.fun-with-values-test/f-args
#'check.fun-with-values-test/f-no-args-value
#'check.fun-with-values-test/f-no-args
#'check.fun-with-values-test/private-f
#'check.fun-with-values-test/f-value)
(f)
@ -41,6 +48,8 @@
(is (= with-fun 42))
(is (= (with-partial 1) 42))
(is (= (f-in-f 1) 42))
(is (= f-no-args-value 42))
(is (= (f-no-args) 42))
(is (= (f-args 41 1) 42))
(is (= (private-f 1) 42))
(is (= f-value 42)))