I'm using ClojureScript and nodejs and I'd like to spawn a child process and deal with the result (stderr, stdout, exit code).
Here's a short gist <https://gist.github.com/frankhenderson/d60471e64faec9e2158c> showing an approach that spawns the process and routes all output to a channel. My goal is to allow the calling code to be written in a straightforward manner instead of having a lot of callbacks. 1. Is using a channel the right idea for avoiding callback hell? 2. I'm routing all three (stderr, stdout, and exit code) to the same channel instead of using a channel for each because it seemed to me that the latter approach would start to feel like callback hell -- 3 separate handling fns vs dealing with a single result vector. On the other hand, whatever code has to handle that single vector, would have those three ideas combined. But I think that's okay.. the ideas stand together. Would you agree? 3. My attempt at avoiding callbacks only lets the calling code deal with the output after the child_process exits instead of along-the-way as the output occurs. Is there a better way that avoids callbacks and yet allows the code to deal with the output as it happens? 4. On line 29 there is a commented-out attempt at adding a timeout. When I use that line instead of 28, I get a Error: No protocol method ICounted.-count defined for type cljs.core.async.impl.channels/ManyToManyChannel. What am I doing wrong? I suppose if it worked, I should change the code to return the process p so it can be killed with a js call if the timeout occurs. 5. Is it correct that I can only access the resulting vector from 'exec' within a go-block? Or.. how does one get something out of the go 'environment' back into normal code? Thanks in advance! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
