aioreactive icon indicating copy to clipboard operation
aioreactive copied to clipboard

Iterable AsyncMultiStream?

Open SF-300 opened this issue 8 years ago • 1 comments

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.

SF-300 avatar Jan 17 '17 13:01 SF-300

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.

dbrattli avatar Jan 18 '17 18:01 dbrattli