- 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.
推薦閱讀
- Vue.js 3.x快速入門
- 數據庫程序員面試筆試真題與解析
- Hyper-V 2016 Best Practices
- FreeSWITCH 1.8
- 少年輕松趣編程:用Scratch創作自己的小游戲
- 算法精粹:經典計算機科學問題的Python實現
- Linux環境編程:從應用到內核
- 老“碼”識途
- Visual C#.NET程序設計
- Web Development with MongoDB and Node(Third Edition)
- MATLAB for Machine Learning
- Visual FoxPro程序設計習題集及實驗指導(第四版)
- Babylon.js Essentials
- Python從入門到精通
- Modern C++ Programming Cookbook