Fork me on GitHub
#core-async
<
2016-06-14
>
ghaskins20:06:32

hi all, new to core.async, trying to use it to interact with a callback flow but things aren’t working as I would expect

ghaskins20:06:59

any suggestions?

exupero20:06:23

use put! instead of >!

ghaskins20:06:37

@exupero: thank you kindly, will try that

exupero20:06:40

You won’t need the go then

ghaskins20:06:38

reading between the lines, I assume >! is only valid if its a first class subordinate of a go form?

exupero21:06:08

Yep. go re-writes its body to support blocking on >! and <! but doesn’t reach into functions within that body.

ghadi21:06:20

lexical scope only

ghaskins21:06:28

hmm, so the problem I am having now is put! is async so I have no flow control

ghaskins21:06:44

(eventually hit the 1k buffer limit and exception out

ghaskins21:06:09

is there any method that is compatible with parking the go-based sender that can be invoked from a callback like that?

ghaskins21:06:31

I could put a promise in the callback for put!, but I feel like I am probably not doing things the intended way, heh

ghaskins21:06:45

my first inclination was to use >!! but it seems that isnt available within clojurescript (for reasons I can guess)

ghaskins21:06:01

unless the reason it wouldnt compile was something else and I misinterpreted the error

exupero21:06:01

You could put the go within the anonymous function. That will create a lot of new goroutines, but they should enqueue their puts in order.

exupero21:06:33

Since you can’t block whether lines are read, you might as well use a list.

exupero21:06:55

You could then iterate over the list and put values onto a channel (if you really needed a channel)