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

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.

主站蜘蛛池模板: 襄城县| 阜城县| 车险| 仁怀市| 新郑市| 调兵山市| 承德市| 江孜县| 蕉岭县| 普陀区| 奎屯市| 龙井市| 乌审旗| 增城市| 沙河市| 巢湖市| 洛南县| 武城县| 贵州省| 莒南县| 武宣县| 甘泉县| 玉屏| 湖口县| 吴忠市| 舒兰市| 天等县| 余江县| 屏南县| 辽阳县| 新河县| 襄汾县| 伽师县| 大同市| 垣曲县| 哈巴河县| 故城县| 绵竹市| 博白县| 青岛市| 沈阳市|