aioreactive
aioreactive copied to clipboard
Iterable AsyncMultiStream?
Hi! I'm wondering why AsyncMultiStream doesn't inherit from AsyncStreamIterable as AsyncSingleStream does? To me it looks pretty reasonable to iterate hot observables because each observer already actually gets individual AsyncSingleStream during subscription.
Hi, the reason is that AsyncSingleStream
is cold while AsyncMultiStream
is hot. Cold means that it will not forward any values before there is a subscriber, and this cannot be enforced with multiple subscribers. But I will most likely remove AsyncStreamIterable
from AsyncSingleStream
as I'm trying to re-align the project with RxPY and going back to the world of Rx abstractions. Instead there will be a to_async_iterable()
function to convert from async push to async pull. To keep the nice syntax for subscribers there will probably be a separate function to use if you want an async iterable instead of a disposable when subscribing, so you can still use async-for
directly.