書名: Hands-On Reactive Programming with Python作者名: Romain Picard本章字數: 95字更新時間: 2021-06-24 18:25:23
The just operator
The just operator returns an observable that emits only one item, and then it completes immediately. The marble diagram of this operator is shown in the following figure:
Figure 4.2: The just operator
Its prototype is as follows:
Observable.just(value, scheduler=None)
The following is an example of how to use it:
number = Observable.just(1)
number.subscribe(
on_next=lambda i: print("item: {}".format(i)),
on_error=lambda e: print("error: {}".format(e)),
on_completed=lambda: print("completed")
)
Upon subscription, the number 1, provided in the just operator, is emitted as the only item of the observable before the observable completes:
推薦閱讀
- Learning Windows Server Containers
- Puppet實戰
- VMware Horizon View 6 Desktop Virtualization Cookbook
- 開源安全運維平臺OSSIM疑難解析:入門篇
- 巧學活用Windows 7
- OpenStack系統架構設計實戰
- iOS 8開發指南
- Windows 7實戰從入門到精通
- Troubleshooting Docker
- Windows 7實戰從入門到精通(超值版)
- Linux操作系統
- Ubuntu Linux操作系統實用教程
- Web Penetration Testing with Kali Linux(Third Edition)
- Linux內核分析及應用
- Windows 8完全自學手冊