aleph

andreas-thoelke 2016-10-09T13:45:53.000338Z

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?

dm3 2016-10-09T13:50:26.000339Z

@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-thoelke 2016-10-09T13:51:48.000341Z

oh, how convenient, thanks!!

andreas-thoelke 2016-10-09T18:14:58.000342Z

@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-thoelke 2016-10-09T18:27:11.000345Z

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.

dm3 2016-10-09T18:45:57.000346Z

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

dm3 2016-10-09T18:47:29.000347Z

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

dm3 2016-10-09T18:48:31.000348Z

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

dm3 2016-10-09T18:51:58.000349Z

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