Fork me on GitHub
Andrei Zah07:11:03

hello everyone, I have a quick question about transducers & async channels. why is it that this works:

(map parse-comment (map :data data))
but this does not:
(def xf
    (map :data)
    (map parse-comment)))
when I use it with an async channel? ->> and transduce both work, it's just when I use it with a chan I start to get nil data. demo code available here:


@zah #(subvec data 0) actually does nothing, it works like identity and with the given xf , your channel expects a map


Think of channel as a vector

Andrei Zah08:11:17

@boldaslove156 sorry I forgot to change the subvec. My real code gets a json response -> converts the stream. (using this lib)


I think you could still get a vector


Check whether you did (put! ch [{:data {...}}]) or (put! ch {:data {...}})

Andrei Zah10:11:32

ah it's [{:data {} }]

Andrei Zah12:11:35

@boldaslove156 is using the vector not possible? the input is [ {:data {}}, {:data {}} ] so into doesn't work as they all get mapped to the same key. here is demo code with real input: