本文整理了Java中io.reactivex.Observable.delay()
方法的一些代码示例,展示了Observable.delay()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.delay()
方法的具体详情如下:
包路径:io.reactivex.Observable
类名称:Observable
方法名:delay
[英]Returns an Observable that emits the items emitted by the source ObservableSource shifted forward in time by a specified delay. Error notifications from the source ObservableSource are not delayed.
Scheduler: This version of delay operates by default on the computation Scheduler.
[中]返回一个Observable,该Observable发出源ObservableSource发出的项,该源ObservableSource在时间上向前移动了指定的延迟。来自源ObservableSource的错误通知不会延迟。
调度程序:默认情况下,此版本的延迟在计算调度程序上运行。
代码示例来源:origin: ReactiveX/RxJava
@Override
public ObservableSource<Object> apply(Observable<Object> o) throws Exception {
return o.delay(1, TimeUnit.SECONDS);
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public ObservableSource<Object> apply(Observable<Object> v) throws Exception {
return v.delay(10, TimeUnit.SECONDS);
}
})
代码示例来源:origin: ReactiveX/RxJava
@Override
public Observable<Integer> apply(Boolean t1) {
return Observable.just(2).delay(500, TimeUnit.MILLISECONDS);
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Observable<Integer> apply(Boolean t1) {
return Observable.just(2).delay(500, TimeUnit.MILLISECONDS);
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public ObservableSource<Integer> apply(Integer i) throws Exception {
return i == 3 ? Observable.just(i) : Observable
.just(i)
.delay(1, TimeUnit.MILLISECONDS, Schedulers.io());
}
})
代码示例来源:origin: ReactiveX/RxJava
@Override
public Integer apply(Integer v) throws Exception {
Observable.just(1).delay(10, TimeUnit.SECONDS).blockingFirst();
return v;
}
})
代码示例来源:origin: ReactiveX/RxJava
@Override
public Integer apply(Integer v) throws Exception {
return Observable.just(2).delay(100, TimeUnit.MILLISECONDS).blockingFirst();
}
})
代码示例来源:origin: ReactiveX/RxJava
@Override
public Integer apply(Integer v) throws Exception {
Observable.just(1).delay(10, TimeUnit.SECONDS).blockingNext().iterator().hasNext();
return v;
}
})
代码示例来源:origin: ReactiveX/RxJava
@Override
public Integer apply(Integer v) throws Exception {
Observable.just(1).delay(10, TimeUnit.SECONDS).blockingFirst();
return v;
}
})
代码示例来源:origin: ReactiveX/RxJava
@Override
public Integer apply(Integer v) throws Exception {
Observable.just(1).delay(10, TimeUnit.SECONDS).blockingSingle();
return v;
}
})
代码示例来源:origin: ReactiveX/RxJava
@Override
public Integer apply(Integer v) throws Exception {
Observable.just(1).delay(10, TimeUnit.SECONDS).blockingLatest().iterator().hasNext();
return v;
}
})
代码示例来源:origin: ReactiveX/RxJava
@Override
public Observable<Integer> apply(Integer x) {
System.out.println("testRepeatRetarget -> " + x);
concatBase.add(x);
return Observable.<Integer>empty()
.delay(200, TimeUnit.MILLISECONDS);
}
})
代码示例来源:origin: ReactiveX/RxJava
@Override
public Integer apply(Integer v) throws Exception {
Observable.just(1).delay(10, TimeUnit.SECONDS).blockingForEach(Functions.emptyConsumer());
return v;
}
})
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void delayBothItemSupplierReturnsNull() {
just1.delay(just1
, new Function<Integer, Observable<Object>>() {
@Override
public Observable<Object> apply(Integer v) {
return null;
}
}).blockingSubscribe();
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void delayWithFunctionReturnsNull() {
just1.delay(new Function<Integer, Observable<Object>>() {
@Override
public Observable<Object> apply(Integer v) {
return null;
}
}).blockingSubscribe();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void skipLastTimedCustomSchedulerDelayError() {
Observable.just(1).concatWith(Observable.just(2).delay(500, TimeUnit.MILLISECONDS))
.skipLast(300, TimeUnit.MILLISECONDS, Schedulers.io(), true)
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void skipLastTimedDefaultScheduler() {
Observable.just(1).concatWith(Observable.just(2).delay(500, TimeUnit.MILLISECONDS))
.skipLast(300, TimeUnit.MILLISECONDS)
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testErrorThrownIssue1685() {
Subject<Object> subject = ReplaySubject.create();
Observable.error(new RuntimeException("oops"))
.materialize()
.delay(1, TimeUnit.SECONDS)
.dematerialize(Functions.<Notification<Object>>identity())
.subscribe(subject);
subject.subscribe();
subject.materialize().blockingFirst();
System.out.println("Done");
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void onCompleteDelayed() {
TestObserver<Object> to = new TestObserver<Object>();
Observable.empty().delay(100, TimeUnit.MILLISECONDS)
.blockingSubscribe(to);
to.assertResult();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void delayWithTimeDelayError() throws Exception {
Observable.just(1).concatWith(Observable.<Integer>error(new TestException()))
.delay(100, TimeUnit.MILLISECONDS, true)
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertFailure(TestException.class, 1);
}
内容来源于网络,如有侵权,请联系作者删除!