Fork me on GitHub
#core-async
<
2019-02-22
>
cjohansen13:02:18

If I have a vector of channels, what is the easiest way to end up with a vector of the first result from each, ordering intact?

cjohansen13:02:06

I tried (for [c chans] (<! c)) but it errors with <! not used in a go block (even when it is)

cjohansen13:02:26

e.g. (go (into [] (for [c chans] (<! c)))) still errors

cjohansen13:02:58

I'm basically looking for the equivalent of Promise.all (for the JS people) for a vector of channels that only emit one message (typically (map f vals) where f uses a go block)

Jan K13:02:44

(<!! (clojure.core.async/map vector your-chans))

cjohansen13:02:21

I tried it, but I misread it first. passing vector as the f does what I want 👍

👍 5