from IPython.display import clear_output
!pip3 install rx
clear_output()
import rx
from rx import of,operators as ops
publisher = of("Apple", "Banna", "PineApple", "Melon", "Strawberry")
"""
# Example 1
"""
def getFruits(minLength):
    return rx.pipe(
        ops.filter(lambda fruit: len(fruit) >= minLength),
    )

publisher.pipe(
   getFruits(6)
).subscribe(lambda value: print("Received {0}".format(value)))
"""
# Example 2
"""
def lowercase():
    
    def _lowercase(source):
        
        def subscribe(observer, scheduler = None):
            def on_next(value):
                observer.on_next(value.lower())

            return source.subscribe(
                on_next,
                observer.on_error,
                observer.on_completed,
                scheduler)
        
        return rx.create(subscribe)
    
    return _lowercase

publisher.pipe(
        lowercase()
     ).subscribe(lambda value: print("Received {0}".format(value)))