ReactiveX / RxPY

ReactiveX for Python
https://rxpy.rtfd.io
MIT License
4.77k stars 361 forks source link

Error in the documentation ? #662

Open tlebrize opened 2 years ago

tlebrize commented 2 years ago

Describe the bug One of the first example of the Get Started documentation fails with:

Traceback (most recent call last):
  File "main.py", line 12, in <module>
    reactivex.of("Alpha", "Beta", "Gamma", "Delta", "Epsilon").pipe(
  File "./venv/lib/python3.8/site-packages/reactivex/observable/observable.py", line 237, in pipe
    return pipe_(self, *operators)
  File "./venv/lib/python3.8/site-packages/reactivex/pipe.py", line 214, in pipe
    return compose(*fns)(__value)
  File "./venv/lib/python3.8/site-packages/reactivex/pipe.py", line 87, in _compose
    return reduce(lambda obs, op: op(obs), operators, source)
  File "./venv/lib/python3.8/site-packages/reactivex/pipe.py", line 87, in <lambda>
    return reduce(lambda obs, op: op(obs), operators, source)
TypeError: 'Observable' object is not callable

The next example in the list also fails in the same way.

To Reproduce Copy the code from the Custom Operator part of the documentation into a file and run it.

The line return rx.pipe( needs to be replaced with return reactivex.pipe( to work with the above imports.

Expected behavior The code should run

Code or Screenshots

import reactivex
from reactivex import operators as ops

def length_more_than_5():
    return reactivex.pipe(
        ops.map(lambda s: len(s)),
        ops.filter(lambda i: i >= 5),
    )

reactivex.of("Alpha", "Beta", "Gamma", "Delta", "Epsilon").pipe(
    length_more_than_5()
).subscribe(lambda value: print("Received {0}".format(value)))

Additional context

wuyuanyi135 commented 1 year ago

According to doc, pipe has been replaced by compose. This inconsistency in the doc also confused me for quite a while.