Is there a way to pass value to observer according to user input (which means that the value being passed is not fixed all the time)?
from rx import Observable, Observer
def push_five_strings(observer,value):
observer.on_next(value)
#observer.on_next("Alpha")
observer.on_completed()
class PrintObserver(Observer):
def on_next(self, value):
print("Received {0}".format(value))
def on_completed(self):
print("Done!")
def on_error(self, error):
print("Error Occurred: {0}".format(error))
strings = [("Alpha", "Beta", "Gamma", "Delta", "Epsilon")]
for i in strings:
push_five_strings(strings) #e.g. getting the values to push in one string at a time from a list of strings
#push_five_strings("Gamma")
#push_five_strings("Alpha")
#push_five_strings("Beta")
#push_five_strings("Delta")
source = Observable.create(push_five_strings)
#source = Observable.from_(["Alpha", "Beta", "Gamma", "Delta", "Epsilon"])
#source = Observable.from_([value])
source.subscribe(PrintObserver())
I've tried searching around trying to understand RxPy, but there is barely any examples around in the Net...