Comments (6)
To split a stream in to multiple streams:
from aioreactive.producer import Producer
import aioreactive.producer.operators as ops
xs = Producer.from_iterable(range(10))
odds = xs | ops.filter(lambda x % 2 == 1)
evens = xs | ops.filter(lambda x: x % 2 == 0)
...
Perfectly ok to ask questions in issues.
from aioreactive.
from aioreactive.
Have a look at this example.
from aioreactive.
Ha cool, that's exactly what I ended up doing. But a side question, If I have a Producer that comes from an iterator, which is essentially reading an async response. If I fork like this, it seems that each instance of the stream with execute the request and get subsequent values from that. I guess this is the expected behavior right?
from aioreactive.
Yes, that is expected behavior. This is what's called "cold" observables in the Rx world. You can turn them "hot" by publishing. Not a 'publish()' operator in aioreactive yet, but you can simulate it by using an AsyncStream
as your sink. Thus you split from the AsyncStream
, then you start the from_iterable()
using your stream instead of the sink (a stream is also a sink).
Something like:
xs = Producer.from_iterable()
ys = AsyncStream()
odds = ys | ops.filter(lambda x: x % 2 == 1)
evens = ys | ops.filter(lambda x: x % 2 == 0)
await start(odds, FuncSink(mysink))
await start(evens, FuncSink(mysink))
await start(xs, ys)
from aioreactive.
Ha, cool. I guess an operator like that would have to mimic what the AsyncStreamFactory does for the start? Create the intermediate stream and connect them up together?
from aioreactive.
Related Issues (20)
- My first AsyncObservable HOT 1
- How can I install this? HOT 3
- Is this project still supported, or has functionality been migrated to RXPY 3.0? HOT 1
- Is this project abandoned? HOT 7
- README unclear HOT 1
- buffer operator? HOT 3
- Observable from an async_generator? HOT 1
- Implementing reduce HOT 3
- Error example autocomplete , web.Application instance initialized with different loop HOT 1
- rx.delay frequently destroys tasks HOT 1
- AttributeError: 'NoneType' object has no attribute 'subscribe_async' in aioreactive/combine.py", line 99, in update HOT 1
- split.py example fails with InvalidStateError HOT 1
- Latest release?
- Python 3.11 support? HOT 11
- ImportError: cannot import name 'match' from 'expression.core' HOT 1
- Thank you for making this lib's type hinting so clean
- AsyncRx.distinct_until_changed, wrong signature HOT 2
- distinct_until_changed, not so nice signature? HOT 1
- feature request: optional comparer argument to distinct_until_changed
- AsyncIteratorObserver takes constructor arguments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aioreactive.