Answer the question
In order to leave comments, you need to log in
Android: function call on RxJava, how?
Hello!
How to implement a function call in RxJava followed by event handling, i.e. timeout or callback?
For example there is:
public Boolean foo(Boolean p){
return !p;
}
Answer the question
In order to leave comments, you need to log in
Можно так:
Observable.create(
new Observable.OnSubscribe<T>() {
@Override
public void call(Subscriber<? super T> sub) {
sub.onNext(okhttp запрос);
sub.onCompleted();
}
})
.map(здесь обрабатывем ответ)
.timeout(5, TimeUnit.SECONDS) //таймаут
.retry(3) // попытки
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(результат -> выводим, сохраняем);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question