RxJava 过滤操作符 distinct 和 distinctUntilChanged
生活随笔
收集整理的這篇文章主要介紹了
RxJava 过滤操作符 distinct 和 distinctUntilChanged
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
distinct? 看下文檔
distinct? : 過濾掉重復的元素
distinctUntilChanged: 過濾掉連續重復的元素,不連續重復的是不過濾
看下代碼
1 distinct
Observable.just(1,1,2,2,3,3,1,2,3).distinct().subscribe(new Consumer<Integer>() {@Overridepublic void accept(Integer integer) throws Throwable {Log.e("--------rxjava",integer.toString());}});
打印結果為
2?distinctUntilChanged?
Observable.just(1,1,2,2,3,3,1,2,3).distinctUntilChanged().subscribe(new Consumer<Integer>() {@Overridepublic void accept(Integer integer) throws Throwable {Log.e("--------rxjava",integer.toString());}});
打印結果為:
總結
以上是生活随笔為你收集整理的RxJava 过滤操作符 distinct 和 distinctUntilChanged的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 不等等不到的人下一句是什么呢?
- 下一篇: RxJava 过滤操作符 throttl