- 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.
- 電腦組裝與系統安裝
- Learning Windows Server Containers
- Arch Linux Environment Setup How-to
- SOA實踐者說
- Extending Puppet
- Windows Server 2012 Hyper-V Cookbook
- 開源安全運維平臺OSSIM疑難解析:入門篇
- 循序漸進學Docker
- Linux網絡內核分析與開發
- 高性能Linux服務器構建實戰:系統安全、故障排查、自動化運維與集群架構
- AutoCAD 2014中文版從入門到精通
- Linux設備驅動開發
- Social Data Visualization with HTML5 and JavaScript
- Cassandra 3.x High Availability(Second Edition)
- Windows Vista終極技巧金典