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

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.

主站蜘蛛池模板: 柳林县| 团风县| 吉隆县| 平武县| 乌兰察布市| 迁西县| 北海市| 沐川县| 哈巴河县| 广丰县| 兖州市| 宜阳县| 蒙城县| 元氏县| 湘乡市| 玛多县| 岢岚县| 荥经县| 库尔勒市| 黄陵县| 崇阳县| 荔波县| 黑山县| 故城县| 银川市| 桂林市| 宽甸| 枣强县| 贡山| 柯坪县| 曲沃县| 汕尾市| 揭东县| 科技| 竹溪县| 万安县| 吉隆县| 蓝山县| 永新县| 武安市| 偃师市|