That is a limitation of Javascript not core.async. Since you cannot block in 
Javascript (only one thread) you have to take the "callback"/async route for 
everything.

Emulating blocking by running a loop is a bad idea since you cannot even 
pause/sleep and while that loop is running nothing else can run, resulting in a 
hanging browser for example.

Don't see why you'd need alt!! though, the (go ...) block should not hurt in 
any way. In Java it may not be the best option since the current thread might 
die but you don't have to worry about that in CLJS.

Just my 2 cents,
/thomas

On Sunday, November 9, 2014 8:50:59 PM UTC+1, Marcus Lewis wrote:
> ClojureScript's core.async doesn't include blocking functions like alts!! and 
> <!!. This generally makes sense, but not always.
> 
> 
> 
> For example, when an error occurs, I think it's sometimes appropriate to 
> drain a channel without closing it. I want to do this:
> 
>     (loop []
>         (alt!!
>           my-channel ([_] (recur))
>           :default :channels-are-drained))
> 
> 
> But instead I'm forced to use alt!, which has to be called from a (go ...) 
> block, which is an arbitrary limitation since this code will never block.
> 
> 
> Thoughts?

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to