Search code examples
pythonreactive-programmingrx-py

reactive programming store result in a variable


quick (trivial) question: I cannot find a way to store the output of a series of operation on an observable in an external variable. For instance something like that:

mylist = []
Observable.from_([1, 2, 3]).to_list().store(mylist)

Not sure this is very "reactive", but should be trivial.

Thanks in advance

C


Solution

  • Turn your observable into a blocking one via .to_blocking(). Now you can iterate over it.

    mylist=list(Observable.from_([1, 2, 3]).to_blocking())                                                                   
    
    print(mylist)