Fork me on GitHub
#core-async
<
2015-10-07
>
swizzard01:10:34

is there a way to put individual results of map (vs the entire seq) into the channel returned by go?

danielcompton02:10:06

@swizzard: I thought the channel returned by go only had one result?

erik_price03:10:08

swizzard: no, the usual way to do this is to create a dedicated out channel and have the go block put its values into that, and ignore the value actually put on go’s return value channel.

jeremyraines20:10:31

is there a pattern for using core.async which is analogous to Q.all() in javascript?

jeremyraines20:10:54

Example: I have an Outfit (collection of maps representing clothing items). Each item must be updated asynchronously, and only once all updates are complete, do something with the "updated" Outfit

erik_price20:10:21

Do you have separate go blocks for each item?

erik_price20:10:21

If so, you can just async/merge their resulting channels into a single channel. If you need to block until all of the merged channels’ values have been delivered on the merged channel, you can use async/into. Of course, you can do a lot of this manually using go-loops and alts!, too.

jeremyraines20:10:43

thanks, I'll check those out

jeremyraines21:10:13

@erik_price: I am trying to do it that way, not sure what I'm doing wrong

jeremyraines21:10:52

once I have the height and width of the image, i'm trying to put it to one channel per item

erik_price21:10:58

It looks like you create a new Image object, but then it just gets garbage collected. Unless I’m misunderstanding something?

jeremyraines21:10:21

yeah, it's created solely for grabbing the height and width

erik_price21:10:13

I see. I’m not a DOM guru, didn’t know that was possible. You’re sure it isn’t being GC’d? Does your onload callback get executed?

jeremyraines21:10:51

yeah. Before I added the a/into it was printing out the first value of the result of a/merge

erik_price21:10:53

I think you want a/map

erik_price21:10:09

no, scratch that

erik_price21:10:12

I was misreading your code

erik_price21:10:24

I dunno Jeremy, it looks right to me

jeremyraines21:10:14

ok, thanks for looking. If I can come up with a good next question, i'll follow up

erik_price21:10:30

That implies that not all of the merged channels are being closed (because until they are, the channel returned from merge doesn’t close, and until that closes, into doesn’t return a channel.

erik_price21:10:41

Ok good luck. I’ll be offline for a bit but back later tonight.

jeremyraines21:10:44

that makes sense

jeremyraines21:10:16

does the merge channel itself need to close? is so how would I know when to do it?

erik_price21:10:34

it does, but it closes automatically when all of the channels passed to merge are closed.

jeremyraines21:10:16

that was it; needed to close the channel onerror since there was a broken image link in my data