本文整理了Java中io.reactivex.Flowable.timer()
方法的一些代码示例,展示了Flowable.timer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flowable.timer()
方法的具体详情如下:
包路径:io.reactivex.Flowable
类名称:Flowable
方法名:timer
[英]Returns a Flowable that emits 0L after a specified delay, and then completes.
Backpressure: This operator does not support backpressure as it uses time. If the downstream needs a slower rate it should slow the timer or use something like #onBackpressureDrop. Scheduler: timer operates by default on the computation Scheduler.
[中]返回在指定延迟后发出0L并完成的可流动数据。
背压:此运算符不支持背压,因为它使用时间。如果下游需要较慢的速度,则应减慢计时器或使用类似于#onBackpressureDrop的方法。调度程序:默认情况下,计时器在计算调度程序上运行。
代码示例来源:origin: ReactiveX/RxJava
@Override
public Flowable<Long> apply(Integer t) {
return Flowable.timer(1, SECONDS, sched);
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Long> call() throws Exception {
if (count++ == 1) {
return null;
}
return Flowable.timer(1, TimeUnit.MILLISECONDS);
}
}, new Callable<Collection<Object>>() {
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Long> createPublisher(final long elements) {
return
Flowable.timer(1, TimeUnit.MILLISECONDS)
.onBackpressureLatest()
;
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Long> call() throws Exception {
if (count++ == 1) {
throw new TestException();
}
return Flowable.timer(1, TimeUnit.MILLISECONDS);
}
}, new Callable<Collection<Object>>() {
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void timerUnitNull() {
Flowable.timer(1, null);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void timerSchedulerNull() {
Flowable.timer(1, TimeUnit.SECONDS, null);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testTimerOnce() {
Flowable.timer(100, TimeUnit.MILLISECONDS, scheduler).subscribe(subscriber);
scheduler.advanceTimeBy(100, TimeUnit.MILLISECONDS);
verify(subscriber, times(1)).onNext(0L);
verify(subscriber, times(1)).onComplete();
verify(subscriber, never()).onError(any(Throwable.class));
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void disposed() {
TestHelper.checkDisposed(Flowable.timer(1, TimeUnit.DAYS));
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void timerDelayZero() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
for (int i = 0; i < 1000; i++) {
Flowable.timer(0, TimeUnit.MILLISECONDS).blockingFirst();
}
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
代码示例来源:origin: ReactiveX/RxJava
@SuppressWarnings("unchecked")
@Test
public void bufferBoundaryHint() {
Flowable.range(1, 5).buffer(Flowable.timer(1, TimeUnit.MINUTES), 2)
.test()
.assertResult(Arrays.asList(1, 2, 3, 4, 5));
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void backpressureNotReady() {
Flowable.timer(1, TimeUnit.MILLISECONDS)
.test(0L)
.awaitDone(5, TimeUnit.SECONDS)
.assertFailure(MissingBackpressureException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void emitLastOther() {
Flowable.just(1)
.sample(Flowable.timer(1, TimeUnit.DAYS), true)
.test()
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void emitLastOtherEmpty() {
Flowable.empty()
.sample(Flowable.timer(1, TimeUnit.DAYS), true)
.test()
.assertResult();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void normalFlowable() {
Maybe.just(1)
.timeout(Flowable.timer(1, TimeUnit.DAYS))
.test()
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void neverFlowable() {
Maybe.never()
.timeout(Flowable.timer(1, TimeUnit.MILLISECONDS))
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertFailure(TimeoutException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void delaySubscriptionFlowable() throws Exception {
Single.just(1).delaySubscription(Flowable.timer(100, TimeUnit.MILLISECONDS))
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void normalFlowableFallback() {
Maybe.just(1)
.timeout(Flowable.timer(1, TimeUnit.DAYS), Maybe.just(2))
.test()
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void neverFlowableFallback() {
Maybe.never()
.timeout(Flowable.timer(1, TimeUnit.MILLISECONDS), Maybe.just(2))
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(2);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void backpressureNoRequest() {
Flowable.just(1)
.debounce(Functions.justFunction(Flowable.timer(1, TimeUnit.MILLISECONDS)))
.test(0L)
.awaitDone(5, TimeUnit.SECONDS)
.assertFailure(MissingBackpressureException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void shouldNotCompleteIfThereArePendingScalarSynchronousEmissionsWhenTheLastInnerSubscriberCompletes() {
TestScheduler scheduler = new TestScheduler();
Flowable<Long> source = Flowable.mergeDelayError(Flowable.just(1L), Flowable.timer(1, TimeUnit.SECONDS, scheduler).skip(1));
TestSubscriber<Long> subscriber = new TestSubscriber<Long>(0L);
source.subscribe(subscriber);
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
subscriber.assertNoValues();
subscriber.assertNotComplete();
subscriber.request(1);
subscriber.assertValue(1L);
// TODO: it should be acceptable to get a completion event without requests
// assertEquals(Collections.<Notification<Long>>emptyList(), subscriber.getOnCompletedEvents());
// subscriber.request(1);
subscriber.assertTerminated();
}
内容来源于网络,如有侵权,请联系作者删除!