take!

added

ns
clojure.core.async

type
function

(take! port fn1) (take! port fn1 on-caller?)

Asynchronously takes a val from port, passing to fn1. Will pass nil
if closed. If on-caller? (default true) is true, and value is
immediately available, will call fn1 on calling thread.
Returns nil.

                user=> (def c (chan 1))
#'user/c

user=> (take! c
              (fn [x]
                (println "Clojure callback value " x)))
nil

user=> (put! c "XYZ")
Clojure callback value  XYZ
true

user=> (put! c "XYZ")
true