I'm trying to use cljs.core.async to convert async code to synchronous, 
I've hit a problem chaining some calls. I'm getting a runtime state machine 
problem, here is a test case for the issue:

(defn td [id t]
>   (let [c (chan)]
>     (window/setTimeout (fn [] (go (>! c (name id)))) t)
>     c
>     ))
>
> (defn tdw [id t]
>   (go
>     (let [id2 (<! (td id 500))
>           c (chan)]
>           (window/setTimeout (fn [] (go (>! c id2))) t)
>           (<! c)
>           ))) 
>
> (defn start []
>   (let [p (fn [v] (.debug js/console (str "v: " v)))]
>     (go
>       (p (<! (td :1 1000)))
>       (p (<! (td :2 1)))
>       (p (<! (tdw :3 200)))
>       )))
>
> The output is :
v: 1 
v: 2 

   1. Uncaught ReferenceError: state_machine__5113__auto____$1 is not 
   defined 


tdw fails in its setTimeout callback.
Is this a legal use case? Have I made a fundamental mistake?

-- 
-- 
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/groups/opt_out.


Reply via email to