- 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.
推薦閱讀
- Access 數據庫應用教程
- Getting Started with PowerShell
- Mastering Yii
- Python高效開發實戰:Django、Tornado、Flask、Twisted(第2版)
- C語言從入門到精通(第4版)
- QGIS:Becoming a GIS Power User
- Java網絡編程核心技術詳解(視頻微課版)
- 好好學Java:從零基礎到項目實戰
- Unity 3D/2D移動開發實戰教程
- C++反匯編與逆向分析技術揭秘(第2版)
- 響應式Web設計:HTML5和CSS3實戰(第2版)
- 從程序員角度學習數據庫技術(藍橋杯軟件大賽培訓教材-Java方向)
- Learning Concurrency in Python
- 零基礎學SQL(升級版)
- Zend Framework 2 Cookbook