本文整理了Java中io.reactivex.Flowable.timeout()
方法的一些代码示例,展示了Flowable.timeout()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flowable.timeout()
方法的具体详情如下:
包路径:io.reactivex.Flowable
类名称:Flowable
方法名:timeout
[英]Returns a Flowable that mirrors the source Publisher but applies a timeout policy for each emitted item. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the resulting Publisher terminates and notifies Subscribers of a TimeoutException.
Backpressure: The operator doesn't interfere with backpressure which is determined by the source Publisher's backpressure behavior. Scheduler: This version of timeout operates by default on the computation Scheduler.
[中]返回一个Flowable,它镜像源发布服务器,但为每个发出的项应用超时策略。如果下一项未在从其前一项开始的指定超时持续时间内发出,则生成的发布服务器将终止并通知订阅者TimeoutException。
背压:操作员不会干扰由源发布者的背压行为确定的背压。调度程序:此版本的超时默认在计算调度程序上运行。
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void timeoutSelectorOtherNull() {
just1.timeout(new Function<Integer, Publisher<Integer>>() {
@Override
public Publisher<Integer> apply(Integer v) {
return just1;
}
}, null);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void timeoutFirstNull() {
just1.timeout((Publisher<Integer>)null, new Function<Integer, Publisher<Integer>>() {
@Override
public Publisher<Integer> apply(Integer v) {
return just1;
}
});
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Integer> createPublisher(long elements) {
return
Flowable.range(0, (int)elements).timeout(1, TimeUnit.DAYS)
;
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void timeoutFirstItemNull() {
just1.timeout(just1, null);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void timeoutSelectorNull() {
just1.timeout(null);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Flowable<Object> apply(Flowable<Object> f) throws Exception {
return f.timeout(Functions.justFunction(Flowable.never()));
}
});
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void timeoutSelectorReturnsNull() {
just1.timeout(new Function<Integer, Publisher<Object>>() {
@Override
public Publisher<Object> apply(Integer v) {
return null;
}
}).blockingSubscribe();
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void timeoutUnitNull() {
just1.timeout(1, null, Schedulers.single(), just1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void timeouOtherNull() {
just1.timeout(1, TimeUnit.SECONDS, Schedulers.single(), null);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Flowable<Object> apply(Flowable<Object> f) throws Exception {
return f.timeout(Functions.justFunction(Flowable.never()), Flowable.never());
}
});
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void timeoutFirstItemReturnsNull() {
just1.timeout(Flowable.never(), new Function<Integer, Publisher<Object>>() {
@Override
public Publisher<Object> apply(Integer v) {
return null;
}
}).blockingSubscribe();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void timedEmpty() {
Flowable.empty()
.timeout(1, TimeUnit.DAYS)
.test()
.assertResult();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void timedEmptyOther() {
Flowable.empty()
.timeout(1, TimeUnit.DAYS, Flowable.just(1))
.test()
.assertResult();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void timedError() {
Flowable.error(new TestException())
.timeout(1, TimeUnit.DAYS)
.test()
.assertFailure(TestException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void empty() {
Flowable.empty()
.timeout(Functions.justFunction(Flowable.never()))
.test()
.assertResult();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void timedAndOther() {
Flowable.never().timeout(100, TimeUnit.MILLISECONDS, Flowable.just(1))
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void timedErrorOther() {
Flowable.error(new TestException())
.timeout(1, TimeUnit.DAYS, Flowable.just(1))
.test()
.assertFailure(TestException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void fallbackErrors() {
Flowable.never()
.timeout(1, TimeUnit.MILLISECONDS, Flowable.error(new TestException()))
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertFailure(TestException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void error() {
Flowable.error(new TestException())
.timeout(Functions.justFunction(Flowable.never()))
.test()
.assertFailure(TestException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void withOtherMainError() {
Flowable.error(new TestException())
.timeout(Functions.justFunction(Flowable.never()), Flowable.never())
.test()
.assertFailure(TestException.class);
}
内容来源于网络,如有侵权,请联系作者删除!