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

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.

主站蜘蛛池模板: 偃师市| 延庆县| 辰溪县| 利川市| 西城区| 抚远县| 襄樊市| 自治县| 吉木萨尔县| 长岭县| 乌拉特后旗| 胶南市| 海口市| 泸州市| 北碚区| 临湘市| 瑞丽市| 平舆县| 铁岭市| 金昌市| 南江县| 新乡市| 闽清县| 南开区| 万荣县| 泾阳县| 三台县| 齐齐哈尔市| 竹北市| 万州区| 右玉县| 清镇市| 余干县| 基隆市| 依兰县| 汽车| 隆昌县| 山西省| 浙江省| 大城县| 宁城县|