Fork me on GitHub
#core-async
<
2017-05-24
>
raymcdermott07:05:19

@joshjones excellent suggestion. Thanks

hlship21:05:00

I'm at a slight loss. I want to do, effectively, the following:

(let [raw-records-ch (get-records)]
   (async/into [] (take 10) raw-records-ch))
In other words, take up to 10 values from raw-records-ch and collect them in a vector, and convey the single vector as the result. However, async/into doesn't support an xform. I can jury-rig something using async/pipe, but it's ugly. Is there a trick I'm missing?

hlship21:05:18

(async/transduce (take 10) conj [] (get-records))
is the best I've come up with.

Alex Miller (Clojure team)21:05:01

That seems to say exactly what you want to do

Alex Miller (Clojure team)21:05:04

An enhancement to add xf to async/into seems reasonable too btw

hlship22:05:00

I'd used transducers but not transduce (core or async) before, so it took a bit of experimentation to work it out.

hlship22:05:43

But a simple core.async patch to add an into arity pretty much like above would be good. Maybe this friday.