Hi Rich,

I like the flexibility of the new watches, but I'm missing a way to
watch for errors. Currently, if an agent's action results in an error
its watchers aren't even triggered.

Thanks,
Anand

On Feb 27, 2:57 pm, Rich Hickey <richhic...@gmail.com> wrote:
> I've added (back)synchronouswatches(svn 1309+), which used to exist
> for agents, now for all reference types.
>
> (defn add-watch
>
>   "Experimental.
>
>   Adds a watch function to an agent/atom/var/ref reference. The watch
>   fn must be a fn of 4 args: a key, the reference, its old-state, its
>   new-state. Whenever the reference's state might have been changed,
>   any registeredwatcheswill have their functions called. The watch
> fn
>   will be called synchronously, on the agent's thread if an agent,
>   before any pending sends if agent or ref. Note that an atom's or
>   ref's state may have changed again prior to the fn call, so use
>   old-state rather than derefing the reference. Note also that watch
> fns
>   may be called from multiple threads simultaneously. Var watchers are
>   triggered only by root binding changes, not thread-local set!s"
>
>  [reference key fn] ...)
>
> (defn remove-watch [reference key]...)
>
> I've left in add/remove-watcher for now, in order to avoid disruption.
> It is defined in terms of add-watch, demonstrating add-watch is the
> more flexible core function. My plan is to remove add-watcher/remove-
> watcher, since you can build your own such variants.
>
> Highlights are:
>
> - Deterministic times when callbacks will occur.
>
> - Provision of before/after state - you determine what constitutes an
> interesting change.
>
> - Arbitrary key will be passed back to callback.
>
> Please try them out for your latest Cells-like and other reactive
> programs. I'd like to move this out of the experimental category.
>
> Feedback and questions welcome,
>
> Rich
--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to