本文整理了Java中io.reactivex.Observable.fromArray()
方法的一些代码示例,展示了Observable.fromArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.fromArray()
方法的具体详情如下:
包路径:io.reactivex.Observable
类名称:Observable
方法名:fromArray
[英]Converts an Array into an ObservableSource that emits the items in the Array.
Scheduler: fromArray does not operate by default on a particular Scheduler.
[中]将数组转换为可观察的源,该源发出数组中的项。
调度程序:默认情况下,fromArray不会在特定调度程序上运行。
代码示例来源:origin: ReactiveX/RxJava
@Override
public Observable<String> apply(Resource res) {
return Observable.fromArray(res.getTextFromWeb().split(" "));
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public Observable<String> apply(Resource resource) {
return Observable.fromArray(resource.getTextFromWeb().split(" "));
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public Observable<String> apply(Resource res) {
return Observable.fromArray(res.getTextFromWeb().split(" "));
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public Observable<String> apply(Resource resource) {
return Observable.fromArray(resource.getTextFromWeb().split(" "));
}
};
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testConcat() {
Observer<String> observer = TestHelper.mockObserver();
final String[] o = { "1", "3", "5", "7" };
final String[] e = { "2", "4", "6" };
final Observable<String> odds = Observable.fromArray(o);
final Observable<String> even = Observable.fromArray(e);
Observable<String> concat = Observable.concat(odds, even);
concat.subscribe(observer);
verify(observer, times(7)).onNext(anyString());
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Observable<String> apply(Resource resource) {
return Observable.fromArray(resource.getTextFromWeb().split(" "))
.concatWith(Observable.<String>error(new RuntimeException()));
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public Observable<String> apply(Resource resource) {
return Observable.fromArray(resource.getTextFromWeb().split(" "))
.concatWith(Observable.<String>error(new RuntimeException()));
}
};
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = IndexOutOfBoundsException.class)
public void testElementAtOrDefaultWithMinusIndex() {
Observable.fromArray(1, 2).elementAt(-1, 0);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void fusionRejected() {
TestObserver<Integer> to = ObserverFusion.newTest(QueueFuseable.ASYNC);
Observable.fromArray(1, 2, 3)
.subscribe(to);
ObserverFusion.assertFusion(to, QueueFuseable.NONE)
.assertResult(1, 2, 3);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testElementAt() {
assertEquals(2, Observable.fromArray(1, 2).elementAt(1).blockingGet()
.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 fromArray() {
String[] items = new String[] { "one", "two", "three" };
assertEquals((Long)3L, Observable.fromArray(items).count().blockingGet());
assertEquals("two", Observable.fromArray(items).skip(1).take(1).blockingSingle());
assertEquals("three", Observable.fromArray(items).takeLast(1).blockingSingle());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testFollowingFirst() {
Observable<Integer> o = Observable.fromArray(1, 3, 5, 6);
Single<Boolean> allOdd = o.all(new Predicate<Integer>() {
@Override
public boolean test(Integer i) {
return i % 2 == 1;
}
});
assertFalse(allOdd.blockingGet());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testWithFollowingFirst() {
Observable<Integer> o = Observable.fromArray(1, 3, 5, 6);
Single<Boolean> anyEven = o.any(new Predicate<Integer>() {
@Override
public boolean test(Integer i) {
return i % 2 == 0;
}
});
assertTrue(anyEven.blockingGet());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testFollowingFirstObservable() {
Observable<Integer> o = Observable.fromArray(1, 3, 5, 6);
Observable<Boolean> allOdd = o.all(new Predicate<Integer>() {
@Override
public boolean test(Integer i) {
return i % 2 == 1;
}
}).toObservable();
assertFalse(allOdd.blockingFirst());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testWithFollowingFirstObservable() {
Observable<Integer> o = Observable.fromArray(1, 3, 5, 6);
Observable<Boolean> anyEven = o.any(new Predicate<Integer>() {
@Override
public boolean test(Integer i) {
return i % 2 == 0;
}
}).toObservable();
assertTrue(anyEven.blockingFirst());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void syncArray() {
Observable.fromArray(new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 })
.to(ObserverFusion.<Integer>test(QueueFuseable.ANY, false))
.assertOf(ObserverFusion.<Integer>assertFusionMode(QueueFuseable.SYNC))
.assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
.assertNoErrors()
.assertComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void checkUnboundedInnerQueue() {
MaybeSubject<Integer> ms = MaybeSubject.create();
@SuppressWarnings("unchecked")
TestObserver<Integer> to = Observable
.fromArray(ms, Maybe.just(2), Maybe.just(3), Maybe.just(4))
.concatMapMaybe(Functions.<Maybe<Integer>>identity(), 2)
.test();
to.assertEmpty();
ms.onSuccess(1);
to.assertResult(1, 2, 3, 4);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void checkUnboundedInnerQueue() {
SingleSubject<Integer> ss = SingleSubject.create();
@SuppressWarnings("unchecked")
TestObserver<Integer> to = Observable
.fromArray(ss, Single.just(2), Single.just(3), Single.just(4))
.concatMapSingle(Functions.<Single<Integer>>identity(), 2)
.test();
to.assertEmpty();
ss.onSuccess(1);
to.assertResult(1, 2, 3, 4);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void syncArrayHidden() {
Observable.fromArray(new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 })
.hide()
.to(ObserverFusion.<Integer>test(QueueFuseable.ANY, false))
.assertOf(ObserverFusion.<Integer>assertNotFuseable())
.assertOf(ObserverFusion.<Integer>assertFusionMode(QueueFuseable.NONE))
.assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
.assertNoErrors()
.assertComplete();
}
内容来源于网络,如有侵权,请联系作者删除!