The ref is a good step, but it seems that accessing it via a global 
variable causes a problem.  

So don't use a global variable.  Pass everything into the Ring handlers via 
the formal parameters.  Compojure-style Ring handlers have only one formal 
parameter, the request map, but you can put anything into it.  In short, 
someone needs to poke the ref into the request map.  In the Ring world, 
functions named "wrap-..." often figure in the creation of the main handler 
precisely to do this sort of thing.  Usually, they put something (like the 
ref) in closure with an anonymous Ring handler that copies it into the 
request map and delegates to downstream handlers. 

By the way, if there is only one value to coordinate (e.g., in a typical 
case, one big map of all knowledge), using a ref is "the hard way" and an 
atom is simpler to deal with.  Same concept, less red tape.  And there can 
usually be just one value to coordinate!  A typical program does not use 
three databases, so why should it need three refs? 

-- 
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/d/optout.

Reply via email to