官术网_书友最值得收藏!

Map operator

Unquestioningly, the most used operator in RxJava is map, which has the following signature:

<R> Observable<R> map(Func1<T, R> func)

The preceding method declaration means that the func function can transform the T object type to the R object type, and applying map transforms Observable<T> into Observable<R>. However, a signature does not always describe the operator's behavior well, especially if the operator is doing a complex transformation. For these purposes, Marble diagrams were invented. Marble diagrams visually present stream transformations. They are so effective for describing the operator's behavior that almost all RxJava operators contain the image with a marble diagram in Javadoc. The map operator is represented by the following diagram:

Diagram 2.7 Operator map: transforms the items emitted by an Observable by applying a function to each item

From looking at the preceding diagram, it should be clear that the map makes a one-to-one transformation. Furthermore, the output stream has the same number of elements as the input stream.

主站蜘蛛池模板: 藁城市| 榆树市| 厦门市| 丹棱县| 赤峰市| 庆阳市| 梧州市| 南皮县| 琼结县| 巴塘县| 永安市| 新和县| 荥经县| 新巴尔虎左旗| 桓仁| 惠水县| 阳谷县| 连南| 射阳县| 资中县| 遂昌县| 合江县| 永德县| 昌平区| 临海市| 西乡县| 南开区| 宝鸡市| 资讯 | 镇平县| 哈巴河县| 澎湖县| 屏东市| 岑巩县| 西充县| 罗江县| 梁平县| 宁陵县| 三门县| 石泉县| 长兴县|