我正在尝试对列表的添加做出可观察的反应,但是我无法这样做。直到我打电话订阅,它才会反应:
>>> from rx import Observer
>>> alist= [1,2,3]
>>> source = Observable.from_list(alist)
>>> source.subscribe(lambda value: print(f'got {value}!'))
got 1!
got 2!
got 3!
>>> alist.append('hi')
>>> source.subscribe(lambda value: print(f'got {value}!'))
got 1!
got 2!
got 3!
got hi!
在将got hi!
附加到列表后,如何执行打印'hi'
这样的动作?