本文整理了Java中rx.Observable.repeatWhen()
方法的一些代码示例,展示了Observable.repeatWhen()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.repeatWhen()
方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:repeatWhen
[英]Returns an Observable that emits the same values as the source Observable with the exception of an onCompleted. An onCompleted notification from the source will result in the emission of a Notification to the Observable provided as an argument to the notificationHandlerfunction. If the Observable returned onCompletes or onErrors then repeatWhen will call onCompleted or onError on the child subscription. Otherwise, this Observable will resubscribe to the source observable.
Scheduler: repeatWhen operates by default on the trampoline Scheduler.
[中]返回一个可观察对象,该对象发出与源可观察对象相同的值,但未完成的值除外。来自源的未完成通知将导致向作为NotificationHandler函数参数提供的可观察对象发出通知。如果可观察到的返回onCompleted或onErrors,则repeatWhen将调用子订阅上的onCompleted或onError。否则,该可观察对象将重新订阅源可观察对象。
调度程序:repeatWhen默认在蹦床调度程序上运行。
代码示例来源:origin: com.nytimes.android/store
@Override
public Observable<T> call(Observable<T> upstream) {
return upstream.repeatWhen(events -> events.switchMap(aVoid -> source));
}
}
代码示例来源:origin: akarnokd/akarnokd-misc
public static void main(String[] args) {
Observable.just(1)
.repeatWhen(o -> Observable.empty())
.subscribe(System.out::println);
}
}
代码示例来源:origin: com.couchbase.client/core-io
.repeatWhen(new Func1<Observable<? extends Void>, Observable<?>>() {
@Override
public Observable<?> call(Observable<? extends Void> observable) {
代码示例来源:origin: couchbase/couchbase-jvm-core
.repeatWhen(new Func1<Observable<? extends Void>, Observable<?>>() {
@Override
public Observable<?> call(Observable<? extends Void> observable) {
代码示例来源:origin: 736008081/frameAndroid
/**
* 轮询 每隔五秒执行一次 订阅消息在子线程中轮询 所以在onErro时不能更新View 需要用Handler通知更新
* 也可以自己设置轮询条件
*
* @param observable
* @param subscriber
* @return
*/
public void setObservable(Observable observable, Subscriber subscriber) {
//取消了订阅, 同时也取消了http请求, RxJavaCallAdapterFactory帮我们给subscriber添加了call.cancel()
Subscription subscribe = observable
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.repeatWhen(new Func1<Observable<? extends Void>, Observable<? extends Void>>() {
@Override
public Observable<? extends Void> call(Observable<? extends Void> observable) {
return observable.delay(5, TimeUnit.SECONDS);
}
}).subscribe(subscriber);
if (mSubscriptionList != null) {
mSubscriptionList.add(subscribe);
}
}
代码示例来源:origin: com.couchbase.client/java-client
.repeatWhen(new Func1<Observable<? extends Void>, Observable<?>>() {
@Override
public Observable<?> call(Observable<? extends Void> observable) {
代码示例来源:origin: akarnokd/akarnokd-misc
private void startPeriodicTransactionRetrieval() {
System.out.println("TransactionSubjectPlaypen.startPeriodicTransactionRetrieval");
TransactionSubjectPlaypen.exceptionType = ExceptionType.OBSERVABLE_EXCEPTION;
Observable.fromCallable(() -> pollRemoteForTransactions(1))
.flatMap(listObservable -> {
return listObservable;
}).flatMapIterable(testTransactions -> {
return testTransactions;
})
.retryWhen(errors -> {
System.out.println("retryWhen");
return errors.flatMap(error -> {
System.out.println("retryWhen: " + error);
return Observable.just(null);
});
})
.repeatWhen(observable -> {
System.out.println("repeatWhen");
return observable.concatMap(v -> timer(4, TimeUnit.SECONDS));
})
.subscribe(transactionSubject);
}
代码示例来源:origin: org.zalando.paradox/paradox-nakadi-consumer-core
private <T> Observable<T> handleRestart(final Observable<T> observable) {
return observable.retryWhen(o -> o.compose(zipWithFlatMap("retry"))).repeatWhen(o ->
o.compose(zipWithFlatMap("repeat")));
}
代码示例来源:origin: com.microsoft.azure/azure-mgmt-cosmosdb
resourceGroupName(),
name()
).repeatWhen(new Func1<Observable<? extends java.lang.Void>, Observable<?>>() {
@Override
public Observable<?> call(Observable<? extends Void> observable) {
代码示例来源:origin: com.couchbase.client/core-io
.repeatWhen(new Func1<Observable<? extends Void>, Observable<?>>() {
@Override
public Observable<?> call(Observable<? extends Void> observable) {
代码示例来源:origin: couchbase/couchbase-jvm-core
.repeatWhen(new Func1<Observable<? extends Void>, Observable<?>>() {
@Override
public Observable<?> call(Observable<? extends Void> observable) {
代码示例来源:origin: Azure/azure-libraries-for-java
resourceGroupName(),
name()
).repeatWhen(new Func1<Observable<? extends java.lang.Void>, Observable<?>>() {
@Override
public Observable<?> call(Observable<? extends Void> observable) {
代码示例来源:origin: com.couchbase.client/core-io
.repeatWhen(new Func1<Observable<? extends Void>, Observable<?>>() {
@Override
public Observable<?> call(Observable<? extends Void> observable) {
代码示例来源:origin: akarnokd/akarnokd-misc
static <T> Observable.Transformer<T, T> debounceFirst(long timeout, TimeUnit unit) {
return f ->
f.publish(g ->
g.take(1)
.concatWith(
g.switchMap(u -> Observable.timer(timeout, unit).map(w -> u))
.take(1)
.ignoreElements()
)
.repeatWhen(h -> h.takeUntil(g.ignoreElements()))
)
;
}
}
代码示例来源:origin: couchbase/couchbase-jvm-core
.repeatWhen(new Func1<Observable<? extends Void>, Observable<?>>() {
@Override
public Observable<?> call(Observable<? extends Void> observable) {
内容来源于网络,如有侵权,请联系作者删除!