This is an extension to a reply to a Reagent user about running multiple async ops in parallel and executing some handler when all finish.
I am wondering if my hunch is correct that CSP is a necessary abstract model for async processes that require complex coordination and/or communication but that it is too much in simple cases like when multiple xhr requests to the server in parallel and running a handler when they all finish passing it the responses as an array. The proof is in the pudding and despite CSP being far more flexible and powerful I can't help but think that for certain cases it is not the ideal solution which brings up my previous question to the list: why call it core.async when in facf it is core.csp? Maybe I'm wrong. If I am show me how to write a simple one line of code in core.async to implement the aforementioned simple case. Here is a copy of my reply on the Ragent list to a user wishing to implement the simple case (too lazy to type it again) "So far, to my understanding, core.async is a CSP implementation that adheres to the Go implementation of CSP. My use of it in JS land is via async-csp (CSP implemented on top of es7 async functions) and has been mostly as a factorization tool, to make pretty and digestible those async patterns that involve coordination and/or communication between async processes. For example, in JS, if you need to run something when N async processes complete and don't want to use the silly '.then' approach, and you don't want to use a dynamic counter approach (not fancy enough for you) you could do it in one line of code within an es7 async function with something like "await Promise.all([asyncOp1, asyncOp2, asyncOp3])" and that is all it takes, definitely more concise that using a CSP pattern. It is try-cath-able, too." Show me the money! No seriously, what am i being an idiot about here? I feel like es7 is giving us more options with async functions and CSP is just a subset of the abstract models that can be implemented via es7's async functions, which I believe are just syntax sugar on top of native Promise. Speaking of Promise, there is a proposal to remove the need for accessing the Promise API in the case presented above using await* (with *) Please educate. Thank you Marc Sent from my iPhone -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
