Hello! I was interested in trying to wrap some callback-hellish JS async functionality into something that would look (and work) like a sync call. I thought that it could be some kind of function which internally uses core.async but does not expose this.
That is instead of having some function with callback on completion (.findSomething jsLib (fn [res] (println res))) I would like to have a sync-variant of it, something like this (defn findSomething [] "returns res" (let [c (chan)] (go (!< (.findSomething jsLib (fn [res] (put! c res))))))) (println (findSomething)) ;; => prints "res" value It would work if go-macro returned last *value* read from the channel. But go macro returns a *channel* that contains the result. So to read it in clojurescript I have to ironically wrap go in go again. Seems like when you started using channels there's no way out of this :) On JVM I could just use <!! in this situation, but it is not supported in ClojureScript. Wanted some advice/pointers from experienced programmers as I've just started and might get something completely wrong :) Thanks in advance, Dmitry. -- 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.