what's the elegant way to convert a rx.Observable object to a 'normal' object in a function?
e.g.:
def foo():
return rx.Observable.just('value').subscribe(<some magic here>)
>>> print(foo())
# expected:
# value
# however get:
# <rx.disposables.anonymousdisposable.AnonymousDisposable at SOME ADDRESS>
I understand that return of subscribe is a disposable object, and a 'ugly' way to implement this is:
class Foo:
def __init__(self):
self.buffer = None
def call_kernel(self):
rx.Observable.just('value').subscribe(lambda v: self.buffer = v)
def __call__(self):
self.call_kernel()
return self.buffer
>>> Foo()
# get:
# value
Is there any better way to do this?
Thanks.