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

  • Learning RxJava
  • Thomas Nield
  • 168字
  • 2021-07-02 22:22:57

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.

主站蜘蛛池模板: 名山县| 瓦房店市| 天津市| 玛曲县| 东明县| 隆林| 大悟县| 什邡市| 东乡族自治县| 洪江市| 盐池县| 昌图县| 敖汉旗| 平湖市| 阳新县| 泾川县| 东丽区| 汉阴县| 奇台县| 东光县| 绍兴市| 东莞市| 宜良县| 工布江达县| 海城市| 昔阳县| 凤城市| 津市市| 龙江县| 库伦旗| 布拖县| 木兰县| 阿克| 江达县| 弥渡县| 新建县| 麻阳| 北流市| 浑源县| 湖南省| 镶黄旗|