dbrattli / aioreactive

Async/await reactive tools for Python 3.11+
MIT License
350 stars 24 forks source link

AsyncIteratorObserver takes constructor arguments #50

Open arnemileswinter opened 4 months ago

arnemileswinter commented 4 months ago

Hello, i noticed that the examples in the readme using AsyncIteratorObserver do not work.

here is how it is in the docs

obv = rx.AsyncIteratorObserver()
async with await xs.subscribe_async(obv) as subscription:
    async for x in obv:
        # do stuff with x

but from my findings it works like this:

obv = rx.AsyncIteratorObserver(xs)
async with await xs.subscribe_async() as subscription:
    async for x in obv:
        # do stuff with x

if i dont do it like this i get an error about missing parameters.

in the test code i found how to use it: https://github.com/dbrattli/aioreactive/blob/cf8bcb82be790a11e43b61703ec5c80d88dca77a/tests/test_async_iteration.py#L44