core-async

dangercoder 2019-03-18T07:44:53.047100Z

Anyone with some good examples of using core async with pipelines? I have 5 non-blocking http calls which needs to be done like 1, 2, 3, 4, 5 (each function returns a core-async-channel). If step 1 fails I cannot continue to step 2 and I must act on this failure. Right now I got theese nested go-blocks.

dangercoder 2019-03-18T07:48:22.047200Z

will try to come up with an example gist later this evening

souenzzo 2019-03-18T18:33:18.049800Z

(async/go 
  (try 
    (let [r1 (async/<! (http/r1))
          r2 (async/<! (http/r2))
          r3 (async/<! (http/r3))
          r4 (async/<! (http/r4))
          r5 (async/<! (http/r5))]
      (prn [:ok r1 r2 r3 r3 r4 r5]))
    (catch Throwable e e)))

dangercoder 2019-03-18T18:59:08.050Z

@souenzzo that code meant more than a thousand words to me. Thank you a lot!

dangercoder 2019-03-18T18:59:42.050200Z

instead of having everything in a go-block I had my own functions with their own go-blocks, making things complex 🙂/ i misunderstood the scoping.