Closed aroemers closed 8 years ago
I believe you already added a "possibility to have a function as a state value" with the power of thought rather than a pull request :) Do you still see a need for this?
ah.. I see what you mean, good catch! I did not want to push it myself since it is your idea, but I'd like to rename things a bit and I'll merge it.
@aroemers: gave it a bit more thought. why do we need trampoline
at all? since it is always `(fn [] ~value)
, we can always just call that fn.
here is where I am coming from.
It will be consistent with the current API: no additional syntax need for an fn-state corner case, and will actually simplify #18 by a lot.
Got to sleep now, but quick response, consider this case:
(defn- start-fn [] ...)
(defstate foo :start start-fn)
@tolitius Not really, what I meant is that start-fn
above is called when starting the state. So, to complete my example:
(defn- start-fn [] "bar")
(defstate foo :start start-fn)
(mount/start)
foo
;=> "bar"
Of course, maybe it is just a trade-off, and functions should not be supported in this way, only forms. Above example would only need this change to work without a trampoline:
(defstate foo :start (start-fn))
@aroemers I'd prefer a simple syntax with the understanding of (f)
vs. f
the idea was that state's :start
will be "invoked" on (mount/start). values came later from @xhh and your contributions :)
@tolitius Alright, I respect that choice. Closing this one then.
Issue #20 adds a lot of flexibility, but removed the possibility to have a function as a state value. This patch brings that back.