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?
@andreas-thoelke: you can copy it from https://github.com/ztellman/manifold/pull/102/files for now - hasn't been merged into Manifold yet.
oh, how convenient, thanks!!
@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:
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.
that's the proper way to do that if you need to process all results
alt
is more useful if what you have are just the deferreds
due to concurrency issues you would never be able to guarantee that only one of the deferreds got processed
or, in your case, if you do take!
, you can't untake!