core-async

2019-02-22T13:23:18.001900Z

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?

2019-02-22T13:25:06.002800Z

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

2019-02-22T13:25:26.003400Z

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

2019-02-22T13:26:58.004500Z

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 K 2019-02-22T13:29:08.005300Z

There's clojure.core.async/map https://clojuredocs.org/clojure.core.async/map

Jan K 2019-02-22T13:29:44.005700Z

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

2019-02-22T13:30:02.006Z

ya

2019-02-22T13:30:21.006400Z

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

1👍