一、repeat语法
public void rxJavaRepeatExample() {
Disposable disposable = Observable.just(1, 2, 3)
.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.repeat()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Integer>() {
@Override
public void accept(Integer integer) throws Exception {
LogUtils.error(TAG, "rxJavaRepeatExample--:" + Thread.currentThread().getName() + "-consumer-:" + integer);
}
});
compositeDisposable.add(disposable);
}
日志
08-22 10:56:44.996 23746-23746/com.example.zhang E/MainPresenter: rxJavaRepeatExample--:main-consumer-:1
rxJavaRepeatExample--:main-consumer-:2
rxJavaRepeatExample--:main-consumer-:3
rxJavaRepeatExample--:main-consumer-:1
rxJavaRepeatExample--:main-consumer-:2
08-22 10:56:44.997 23746-23746/com.example.zhang E/MainPresenter: rxJavaRepeatExample--:main-consumer-:3
rxJavaRepeatExample--:main-consumer-:1
rxJavaRepeatExample--:main-consumer-:2
rxJavaRepeatExample--:main-consumer-:3
rxJavaRepeatExample--:main-consumer-:1
08-22 10:56:44.998 23746-23746/com.example.zhang E/MainPresenter: rxJavaRepeatExample--:main-consumer-:2
rxJavaRepeatExample--:main-consumer-:3
rxJavaRepeatExample--:main-consumer-:1
rxJavaRepeatExample--:main-consumer-:2
rxJavaRepeatExample--:main-consumer-:3
08-22 10:56:44.999 23746-23746/com.example.zhang E/MainPresenter: rxJavaRepeatExample--:main-consumer-:1
rxJavaRepeatExample--:main-consumer-:2
rxJavaRepeatExample--:main-consumer-:3
总结
1、repeat无限期发送
河马过河微信公众号.jpg
网友评论