本文整理了Java中io.reactivex.Flowable.elementAt()
方法的一些代码示例,展示了Flowable.elementAt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flowable.elementAt()
方法的具体详情如下:
包路径:io.reactivex.Flowable
类名称:Flowable
方法名:elementAt
[英]Returns a Maybe that emits the single item at a specified index in a sequence of emissions from this Flowable or completes if this Flowable sequence has fewer elements than index.
Backpressure: The operator honors backpressure from downstream and consumes the source Publisher in an unbounded manner (i.e., no backpressure applied to it). Scheduler: elementAt does not operate by default on a particular Scheduler.
[中]返回一个值,该值在此可流动序列的排放序列中以指定的索引排放单个项目,或者如果此可流动序列的元素少于索引,则返回完成。
背压:操作员接受来自下游的背压,并以无限制的方式使用源发布服务器(即,不向其施加背压)。Scheduler:elementAt默认情况下不会在特定的计划程序上运行。
代码示例来源:origin: ReactiveX/RxJava
@Override
public Single<Object> apply(Flowable<Object> f) throws Exception {
return f.elementAt(0, 1);
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Object apply(Flowable<Integer> f) throws Exception {
return f.elementAt(0);
}
}, false, null, 1);
代码示例来源:origin: ReactiveX/RxJava
@Override
public Object apply(Flowable<Integer> f) throws Exception {
return f.elementAt(0, 1);
}
}, false, null, 1, 1);
代码示例来源:origin: ReactiveX/RxJava
@Override
public Object apply(Flowable<Integer> f) throws Exception {
return f.elementAt(0, 1).toFlowable();
}
}, false, null, 1, 1);
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void elementAtNull() {
just1.elementAt(1, null);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Object> apply(Flowable<Object> f) throws Exception {
return f.elementAt(0).toFlowable();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Object apply(Flowable<Integer> f) throws Exception {
return f.elementAt(0).toFlowable();
}
}, false, null, 1);
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = IndexOutOfBoundsException.class)
public void testElementAtWithMinusIndexFlowable() {
Flowable.fromArray(1, 2).elementAt(-1);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Integer> createPublisher(final long elements) {
return
Flowable.range(1, 10).elementAt(5).toFlowable()
;
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAt() {
assertEquals(2, Flowable.fromArray(1, 2).elementAt(1).blockingGet()
.intValue());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAtOrDefault() {
assertEquals(2, Flowable.fromArray(1, 2).elementAt(1, 0).blockingGet().intValue());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAtWithIndexOutOfBoundsFlowable() {
assertEquals(-100, Flowable.fromArray(1, 2).elementAt(2).toFlowable().blockingFirst(-100).intValue());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAtFlowable() {
assertEquals(2, Flowable.fromArray(1, 2).elementAt(1).toFlowable().blockingSingle()
.intValue());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void elementAtIndex0WithDefaultOnEmptySource() {
Flowable.empty()
.elementAt(0, 5)
.test()
.assertResult(5);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void elementAtIndex1WithDefaultOnEmptySource() {
Flowable.empty()
.elementAt(1, 10)
.test()
.assertResult(10);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void elementAtIndex0OnEmptySource() {
Flowable.empty()
.elementAt(0)
.test()
.assertResult();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void elementAtIndex1OnEmptySource() {
Flowable.empty()
.elementAt(1)
.test()
.assertResult();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void error() {
Flowable.error(new TestException())
.elementAt(1, 10)
.test()
.assertFailure(TestException.class);
Flowable.error(new TestException())
.elementAt(1)
.test()
.assertFailure(TestException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void elementAtIndex1WithDefaultOnEmptySourceObservable() {
Flowable.empty()
.elementAt(1, 10)
.toFlowable()
.test()
.assertResult(10);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void errorFlowable() {
Flowable.error(new TestException())
.elementAt(1, 10)
.toFlowable()
.test()
.assertFailure(TestException.class);
}
内容来源于网络,如有侵权,请联系作者删除!