This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-19
Channels
- # bangalore-clj (1)
- # beginners (8)
- # boot (102)
- # cider (1)
- # clara (14)
- # cljs-dev (2)
- # cljsrn (2)
- # clojure (49)
- # clojure-poland (3)
- # clojure-russia (4)
- # clojure-serbia (1)
- # clojure-spec (5)
- # clojure-ukraine (1)
- # clojurescript (181)
- # core-async (4)
- # cursive (2)
- # datomic (7)
- # dirac (34)
- # figwheel (3)
- # fulcro (21)
- # hoplon (5)
- # om (1)
- # parinfer (4)
- # planck (27)
- # re-frame (30)
- # reagent (11)
- # rum (6)
- # shadow-cljs (22)
- # spacemacs (4)
- # unrepl (26)
hello everyone, I have a quick question about transducers & async channels. why is it that this works:
clojure
(map parse-comment (map :data data))
but this does not:
clojure
(def xf
(comp
(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: https://hastebin.com/ewuxeyihul.lisp@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
@boldaslove156 sorry I forgot to change the subvec. My real code gets a json response -> converts the stream. (using this lib) https://github.com/dakrone/cheshire
I think you could still get a vector
Check whether you did (put! ch [{:data {...}}])
or (put! ch {:data {...}})
ah it's [{:data {} }]
@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: https://hastebin.com/vunohahovu.lisp