Fork me on GitHub
#core-async
<
2015-12-05
>
mrmcc306:12:57

Hello. I’m trying to get my head around promise-chan in clojurescript. I have the following code

(let [pch (promise-chan)]
  (go
    (<! pch)
    (.log js/console "message a"))
  (go
    (<! pch)
    (.log js/console "message b"))
  (go
    (>! pch true)))
I was expecting to receive both messages but i’m only getting “message a”. Am i missing something here?

Alex Miller (Clojure team)13:12:18

The intent is that you receive both

Alex Miller (Clojure team)13:12:28

When you put to a promise-chan it should deliver to all pending takers

mrmcc313:12:19

hmm yeah thats what i was expecting

Alex Miller (Clojure team)16:12:51

@mrmcc3: I'm assuming you're using the latest (0.2.374) ?

Alex Miller (Clojure team)16:12:50

there are tests in the core.async cljs test suite very similar to this that pass

mrmcc321:12:18

I’m using the latest 0.2.374. It works as expected in clojure. Similar to the tests I can produce both messages if i use an outer go block

(let [pch (promise-chan)]
  (go
    (go
      (<! pch)
      (.log js/console "message a"))
    (go
      (<! pch)
      (.log js/console "message b"))
    (>! pch true)))