Fork me on GitHub
#aleph
<
2016-10-09
>
andreas-thoelke13:10:53

I everyone! I have a manifold questions: Is there something like core.async/alt! in manifold where I can wait for the next message on either one of several streams, or wait for the first of several deferreds to become resolved?

dm313:10:26

@andreas-thoelke: you can copy it from https://github.com/ztellman/manifold/pull/102/files for now - hasn't been merged into Manifold yet.

andreas-thoelke13:10:48

oh, how convenient, thanks!!

andreas-thoelke18:10:58

@dm3 thanks for this patch, it works as described. I was hoping though alt would allow me to get similar behavior to core.async/alt! or alts!, however it seems it would have had to somehow cancel the leftover deferred/take! in order to not swallow values like in this example:

andreas-thoelke18:10:11

It seems the only way to do this in manifold is to merge/connect the two streams into one and then take from this combined stream.

dm318:10:57

that's the proper way to do that if you need to process all results

dm318:10:29

alt is more useful if what you have are just the deferreds

dm318:10:31

due to concurrency issues you would never be able to guarantee that only one of the deferreds got processed

dm318:10:58

or, in your case, if you do take!, you can't untake!