- 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:
推薦閱讀
- Linux設(shè)備驅(qū)動開發(fā)詳解:基于最新的Linux4.0內(nèi)核
- Getting Started with oVirt 3.3
- 白話區(qū)塊鏈
- Linux性能優(yōu)化
- 混沌工程實戰(zhàn):手把手教你實現(xiàn)系統(tǒng)穩(wěn)定性
- Windows 7中文版從入門到精通(修訂版)
- Learning Bootstrap
- VMware NSX Cookbook
- Application Development in iOS 7
- Django Project Blueprints
- 分布式系統(tǒng)設(shè)計實踐
- Linux內(nèi)核API完全參考手冊(第2版)
- VMware Horizon Mirage Essentials
- Linux從入門到精通(視頻教學(xué)版)
- Getting Started with UDK