I use the following code to realize the countdown display at the millisecond level. After onSubscribe is executed, the onNext method is executed nearly one minute later.
This problem occurs occasionally. This problem also exists when creating Observable using the create method.
I don't have any solutions at present. Please help me, thank you
Observable.interval(1900, 50, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnDispose(() -> {
XLog.i("doOnDispose");
})
.compose(RxUtils.bindToLifecycle(provider))
.subscribe(new Observer<Long>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
XLog.i("onSubscribe");
}
@Override
public void onNext(@NonNull Long aLong) {
XLog.i("onNext");
// refresh ui countdown
}
@Override
public void onError(@NonNull Throwable e) {
XLog.i("onError");
}
@Override
public void onComplete() {
XLog.i("onComplete");
}
});
I don't have any solutions at present