core-async

mschaef 2019-03-14T09:37:12.030300Z

Is there an idiomatic way in core.async to make a sort of combining stream? Let’s say I have a function (fn [x y] ..., one channel for x and another channel for y. What I’m looking for is a channel that contains the result (f x y) for every inbound update to either x or y.

mpenet 2019-03-14T09:39:46.030500Z

core.async/map ?

mschaef 2019-03-14T09:43:02.031500Z

That looks like it would consume x and y in pairs, no? (So if an x arrives with no y, there’d be no update until it gets a y too?)

mccraigmccraig 2019-03-14T10:23:32.034600Z

@mike566 have a look at alts! - if i understand correctly you want to use cached values of x or y to correspond to the latest value from whichever channel delivers first, so perhaps cache x and y in a go block and use alts! to get new values ?

mschaef 2019-03-14T10:24:40.035400Z

@mccraigmccraig Thanks! I’ll take a look and see. (What you’re saying about using cached values is what I was trying to get at.)