Fork me on GitHub
#beginners
<
2017-02-20
>
joshkh16:02:11

quick question about channels! i have a collection of maps, each with an :id and a :chan. i want to map over them and take their values as they come back in. what might i be doing wrong?

(def some-channel-maps [{:id "abc" :chan a-channel} {:id "xyz" :chan a-channel}])

(go
  (doall (map (fn [{:keys [chan id]}]
                (println "GOT" (<! chan) "from" id)))
         some-channel-maps))

joshkh16:02:39

i never get a printed statement but i know they have a value

dominicm17:02:20

@joshkh Do you have anything on a-channel?

dominicm17:02:52

You can do a println before/after the current one to check if a-channel is what is the blocker

joshkh17:02:30

yup, the channels have a take-able value. if i isolate the first channel in the sequence and take from it directly outside of the map then i get a value.

joshkh17:02:08

maybe it's the position of the go block. if i move the 'go' into its own function then it seems to work:

(defn single [{:keys [path chan] :as s}]
  (go (dispatch [:qb/some-event path (<! chan)])))

(fn [chans] (doall (map single chans)))

dominicm17:02:15

Your closing parens are misplaced

dominicm17:02:20

the list is outside the map

joshkh17:02:44

a big sheepish thanks!

dominicm17:02:33

No problem.

sudodoki19:02:03

👋 have an issue with setting up reagent-template and drift's lein create-migration, would be grateful for advise. Tried putting down description in gist here: https://gist.github.com/sudodoki/98b422931a79301ed0f543df29306fb7