This is a proposal for a (simplistic) implementation of Stream.select, which permits watching multiple streams and returning the first item yielded by any of them. It works for the intended use case, although at this point there are two weaknesses, both due to the underlying implementation using Fiber.any:
Only streams of the same item type can be selected across (just like Fiber.any only works with fiber functions yielding the same type)
If two or more streams are ready at the same time, all but one elements will be discarded (just like Fiber.any). This is documented, but still not desirable.
Thanks for considering this - I'd be happy to hear proposals for making this functionality more general, or just not based on the Fiber functions which restrict what can be done here. So please consider it a starting point :-)
(for #577)
This is a proposal for a (simplistic) implementation of
Stream.select
, which permits watching multiple streams and returning the first item yielded by any of them. It works for the intended use case, although at this point there are two weaknesses, both due to the underlying implementation usingFiber.any
:Fiber.any
only works with fiber functions yielding the same type)Fiber.any
). This is documented, but still not desirable.Thanks for considering this - I'd be happy to hear proposals for making this functionality more general, or just not based on the
Fiber
functions which restrict what can be done here. So please consider it a starting point :-)