- Hands-On Reactive Programming with Python
- Romain Picard
- 176字
- 2021-06-24 18:25:13
The map operator
Let's see a real example with the map operator. This operator takes a source observable as input and returns an observable as output. It applies a function to each item of the source observable, and emits the result of this function on the output observable. Hopefully, its marble diagram, shown in the following figure, should make the description much more clear:
The marble diagram shows an input timeline with three integer items: 1, 12, and 7. The transformation is described with syntax similar to that of the Python lambda. Note that the official ReactiveX documentation uses the JavaScript arrow function notation, because it uses marble diagrams from the JavaScript implementation. In this example, the transformation is a multiplication by 3 of the source item. The output timeline contains also three items, corresponding to the input items values multiplied by 3.
The prototype of this operator is the following one:
Observable.map(self, selector)
The selector parameter is the function that will be executed on all items of the input observable.
- Windows Server 2019 Cookbook
- Linux Mint Essentials
- UNIX操作系統設計
- 移動應用UI設計模式(第2版)
- Learning Bootstrap
- Linux系統安全基礎:二進制代碼安全性分析基礎與實踐
- Windows 7中文版從入門到精通(修訂版)
- 嵌入式實時操作系統:RT-Thread設計與實現
- 無蘋果不生活 The New iPad隨身寶典
- Windows 7應用入門與技巧
- Linux服務器配置與管理
- RHCSARHCE 紅帽Linux認證學習指南(第7版)EX200 & EX300
- Linux內核API完全參考手冊(第2版)
- 大學計算機應用基礎實踐教程(Windows 7+MS Office 2010)
- Docker容器技術與應用