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

skip()

The skip() operator does the opposite of the take() operator. It will ignore the specified number of emissions and then emit the ones that follow.  If I wanted to skip the first 90 emissions of an Observable, I could use this operator, as shown in the following code snippet:

import io.reactivex.Observable;

public class Launcher {
public static void main(String[] args) {

Observable.range(1,100)
.skip(90)
.subscribe(i -> System.out.println("RECEIVED: " + i));
}
}

The output of the following code snippet is as follows:

RECEIVED: 91
RECEIVED: 92
RECEIVED: 93
RECEIVED: 94
RECEIVED: 95
RECEIVED: 96
RECEIVED: 97
RECEIVED: 98
RECEIVED: 99
RECEIVED: 100

Just like the take() operator, there is also an overload accepting a time duration. There is also a skipLast() operator, which will skip the last specified number of items (or time duration) before the onComplete() event is called. Just keep in mind that the skipLast() operator will queue and delay emissions until it confirms the last emissions in that scope.

主站蜘蛛池模板: 安西县| 岳池县| 曲松县| 留坝县| 河南省| 江口县| 右玉县| 德保县| 桑日县| 伽师县| 锡林浩特市| 岳阳市| 万州区| 九寨沟县| 新晃| 金湖县| 平山县| 威宁| 长子县| 东城区| 焉耆| 寿宁县| 仪陇县| 邵东县| 金寨县| 健康| 黎平县| 石狮市| 昌平区| 宜都市| 红桥区| 通化市| 思南县| 密山市| 普定县| 鄂尔多斯市| 那曲县| 繁昌县| 稻城县| 泗洪县| 阳东县|