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

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.

主站蜘蛛池模板: 石嘴山市| 台南县| 清远市| 金门县| 崇文区| 株洲市| 巴马| 建阳市| 龙川县| 贡嘎县| 公主岭市| 象州县| 德昌县| 马关县| 罗城| 梨树县| 疏附县| 虎林市| 邹城市| 报价| 石景山区| 海林市| 蒙城县| 当阳市| 孟村| 黑山县| 凤山县| 青神县| 凭祥市| 固镇县| 涞水县| 静宁县| 乌鲁木齐县| 石棉县| 桃园市| 衡水市| 天津市| 姚安县| 高淳县| 和林格尔县| 镇江市|