Okay, got it. It looks like you're using agents where I'd been using atoms. Not sure if there's much of a difference for these use cases... the one-directional flow of source -> state -> watcher update notification -> ui change seems to work well with both agents and atoms.

Brian Marick wrote:
On Nov 30, 2013, at 10:39 AM, Sam Ritchie<sritchi...@gmail.com>  wrote:

Brian, I like that too. It looks like you're providing the state when you do 
the def-action?

If I understand the question right, yes. A test of a state function would look 
like:

(fact
   (incrementer {:value 1} 3) =>  {:value 4}))

Is the "self" variable "state", captured through the closure?

`self` is the agent, whose dereference is passed in as the symbol named `state`.

That part I'm uncomfortable with. I've put each agent in a namespace with its 
action functions. The convention is that the agent is named `self`, and 
`def-action` knows that convention. It works, but it reminds me too much of 
singletons and all those cases where you start out thinking a single instance 
is all you'll ever need and then discover you were wrong.

--------
Latest book: /Functional Programming for the Object-Oriented Programmer/
https://leanpub.com/fp-oo


--
Sam Ritchie (@sritchie)
Paddleguru Co-Founder
703.863.8561
www.paddleguru.com <http://www.paddleguru.com/>
Twitter <http://twitter.com/paddleguru>// Facebook <http://facebook.com/paddleguru>

--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to