- 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.
推薦閱讀
- Python從小白到大牛
- Mastering Entity Framework
- Internet of Things with the Arduino Yún
- Elastic Stack應用寶典
- Visual Basic程序設計與應用實踐教程
- PySide GUI Application Development(Second Edition)
- BeagleBone Black Cookbook
- Java實戰(第2版)
- Unity 3D腳本編程:使用C#語言開發跨平臺游戲
- Clojure for Java Developers
- HTML5移動前端開發基礎與實戰(微課版)
- Jakarta EE Cookbook
- 網絡綜合布線與組網實戰指南
- 高質量程序設計指南:C++/C語言
- 你必須知道的.NET(第2版)