core-async

bertofer 2019-12-05T09:35:46.250400Z

Is there any way in core.async to have something similar to an alts! that take from different channels, but that it will take from all channels available, instead of picking 1 randomly?

mpenet 2019-12-05T10:12:20.250700Z

a/merge

bertofer 2019-12-05T10:15:27.251300Z

Was thinking something that would retrieve all of them on 1 pass

bertofer 2019-12-05T10:16:13.252200Z

But I think what I am looking would be to iterate all channels with poll! and return a map of the ones with values

alexmiller 2019-12-05T14:20:02.252600Z

well you just wrote the code in that line

alexmiller 2019-12-05T14:20:34.253Z

a/map kind of is like that, but doesn't poll! http://clojure.github.io/core.async/#clojure.core.async/map

alexmiller 2019-12-05T14:21:13.253500Z

in short, no, but it's pretty easy to write

bertofer 2019-12-05T14:37:33.255500Z

Problem with map for my use case is that maybe not all channels might have an available value, and that would prevent the others from being taken. I am rethinking how to handle this case, as I think I was approaching it from the wrong perspective for what I need. Thanks for the help!

Filipe Silva 2019-12-05T14:57:10.256200Z

uhm.... I think what you want is a map where you apply alts between the element and a timeout

Filipe Silva 2019-12-05T14:58:49.256700Z

that'd mean "I want all results available by this timeout"

alexmiller 2019-12-05T15:02:31.257Z

but you'd only get one result, not all available

alexmiller 2019-12-05T15:03:04.257300Z

unless you're saying to build a thing that did that

bertofer 2019-12-05T15:15:48.258500Z

What I was thinkingt was more like an alts that would take all available when more than one are available, but in the end I changed the approach to not need this at all and use common core.async fns