There is no best approach for this. Yes, you do end up blocking the request
thread, but that’s what needs to happen if you the response requires the
value returned by the channel. You can’t return a response to the browser
and then change it later when the channel sends its value. (You’d have the
same problem with Rx, btw.)

The closest equivalent to Rx’s complete event is that a channel is closed
(in which case anything blocked or parked on that channel will receive nil).

e
​

On Wed, Mar 25, 2015 at 12:08 AM, coco <clasesparticulares...@gmail.com>
wrote:

> Hi guys...I've a code similar to this:
>
> (defn user-data []
>   (!/go
>     (let [a             (!/<! (<fun-async 2))
>           b              (!/<! (<fun-async a))]
>       {:response b})))
>
> (defn handler-something []
>   (let [data (!/<!! (user-data))] ;;block here
>     (print data)
>     (response  data......)))
>
> user-data do a sucession of async calls and return a channel (because it's
> inside a go block no?)
> my handler-something need extract this data and return it in a ring
> response...I can wrap my response function inside a go block, if I do this
> I get
>
> java.lang.IllegalArgumentException: No implementation of method: :render
> of protocol: #'compojure.response/Renderable found for class:
> clojure.core.async.impl.channels.ManyToManyChannel
>
> so basically I use a block get <!! and then return the data...I'm more
> familiar with FRP and in FRP I would use a "onComplete" method which
> basically do the same as <!!
>
> this pattern is correct or I'll end blocking code?...which could be the
> best approach for this?..thanks!
>
>
>  --
> 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.
>

-- 
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