- 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:
推薦閱讀
- Getting Started with oVirt 3.3
- Linux系統架構與運維實戰
- Google系統架構解密:構建安全可靠的系統
- 精通Linux內核開發
- Windows Phone 7.5 Data Cookbook
- SharePoint 2013 應用開發實戰
- Linux操作系統應用編程
- Windows Server 2019 Administration Fundamentals
- Windows 7中文版從入門到精通(修訂版)
- 嵌入式實時操作系統:RT-Thread設計與實現
- Windows Server 2012網絡操作系統項目教程(第4版)
- Learn Quantum Computing with Python and IBM Quantum Experience
- Linux系統管理初學者指南:基于CentOS 7.6
- Hadoop Operations and Cluster Management Cookbook
- Xamarin Mobile Application Development for Android