本文整理了Java中io.reactivex.Observable.elementAt()
方法的一些代码示例,展示了Observable.elementAt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.elementAt()
方法的具体详情如下:
包路径:io.reactivex.Observable
类名称:Observable
方法名:elementAt
[英]Returns a Maybe that emits the single item at a specified index in a sequence of emissions from this Observable or completes if this Observable signals fewer elements than index.
Scheduler: elementAt does not operate by default on a particular Scheduler.
[中]返回一个值,该值在该可观测项的一系列发射中以指定的索引发射单个项目,或者如果该可观测项发出的信号少于索引,则返回完成。
Scheduler:elementAt默认情况下不会在特定的计划程序上运行。
代码示例来源:origin: ReactiveX/RxJava
@Override
public SingleSource<Object> apply(Observable<Object> o) throws Exception {
return o.elementAt(0, 1);
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public MaybeSource<Object> apply(Observable<Object> o) throws Exception {
return o.elementAt(0);
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public ObservableSource<Object> apply(Observable<Object> o) throws Exception {
return o.elementAt(0).toObservable();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void elementAtNull() {
just1.elementAt(1, null);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = IndexOutOfBoundsException.class)
public void testElementAtOrDefaultWithMinusIndex() {
Observable.fromArray(1, 2).elementAt(-1, 0);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = IndexOutOfBoundsException.class)
public void testElementAtWithMinusIndex() {
Observable.fromArray(1, 2).elementAt(-1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAt() {
assertEquals(2, Observable.fromArray(1, 2).elementAt(1).blockingGet()
.intValue());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAtOrDefaultWithIndexOutOfBounds() {
assertEquals(0, Observable.fromArray(1, 2).elementAt(2, 0).blockingGet().intValue());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAtOrDefault() {
assertEquals(2, Observable.fromArray(1, 2).elementAt(1, 0).blockingGet().intValue());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAtOrDefaultWithIndexOutOfBoundsObservable() {
assertEquals(0, Observable.fromArray(1, 2).elementAt(2, 0).toObservable().blockingSingle().intValue());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAtObservable() {
assertEquals(2, Observable.fromArray(1, 2).elementAt(1).toObservable().blockingSingle()
.intValue());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void elementAtIndex0WithDefaultOnEmptySource() {
Observable.empty()
.elementAt(0, 5)
.test()
.assertResult(5);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAtOrDefaultObservable() {
assertEquals(2, Observable.fromArray(1, 2).elementAt(1, 0).toObservable().blockingSingle().intValue());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAtWithIndexOutOfBoundsObservable() {
assertEquals(-99, Observable.fromArray(1, 2).elementAt(2).toObservable().blockingSingle(-99).intValue());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAtWithIndexOutOfBounds() {
assertNull(Observable.fromArray(1, 2).elementAt(2).blockingGet());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void elementAtIndex0OnEmptySource() {
Observable.empty()
.elementAt(0)
.test()
.assertResult();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void elementAtIndex1OnEmptySource() {
Observable.empty()
.elementAt(1)
.test()
.assertResult();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void elementAtIndex1WithDefaultOnEmptySource() {
Observable.empty()
.elementAt(1, 10)
.test()
.assertResult(10);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void elementAtIndex1WithDefaultOnEmptySourceObservable() {
Observable.empty()
.elementAt(1, 10)
.toObservable()
.test()
.assertResult(10);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void errorObservable() {
Observable.error(new TestException())
.elementAt(1, 10)
.toObservable()
.test()
.assertFailure(TestException.class);
}
内容来源于网络,如有侵权,请联系作者删除!