去重。比较简单的作用,玩过数据库的看到这个单词应该也挺眼熟的。
Observable.just(1, 2, 1, 1, 2, 3, 4, 6, 4)
// Run on a background thread
.subscribeOn(Schedulers.io())
// Be notified on the main thread
.observeOn(AndroidSchedulers.mainThread())
.distinct()//就是去重操作
.subscribe(getObserver());//这里的观察者依然不重要
1,2,3,4,6
我们创建了一个会发送1, 2, 1, 1, 2, 3, 4, 6, 4 这些item的被观察者 其中1,2,4都有重复的数字 然后用操作符distinct去掉重复的数字 最后,我们从观察者中拿到的item为1,2,3,4,6
这个系列只有干货,如果大家有什么好的建议的话欢迎在下面评论。或者觉得我哪里写的不够形象了,同样可以提出来。