本文整理了Java中io.reactivex.Single.concat()
方法的一些代码示例,展示了Single.concat()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Single.concat()
方法的具体详情如下:
包路径:io.reactivex.Single
类名称:Single
方法名:concat
[英]Concatenate the single values, in a non-overlapping fashion, of the Single sources provided by an Observable sequence. Scheduler: concat does not operate by default on a particular Scheduler.
[中]以不重叠的方式连接由可观察序列提供的单个源的单个值。调度器:默认情况下,concat不会在特定的调度器上运行。
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void concatObservableNull() {
Single.concat((Flowable<Single<Integer>>)null);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void concatIterableNull() {
Single.concat((Iterable<Single<Integer>>)null);
}
代码示例来源:origin: ReactiveX/RxJava
@SuppressWarnings("unchecked")
@Test(expected = NullPointerException.class)
public void concatIterableOneIsNull() {
Single.concat(Arrays.asList(just1, null)).blockingSubscribe();
}
代码示例来源:origin: ReactiveX/RxJava
/**
* Returns a Flowable that emits the item emitted by the source Single, then the item emitted by the
* specified Single.
* <p>
* <img width="640" height="335" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Single.concatWith.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The returned {@code Flowable} honors the backpressure of the downstream consumer.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code concatWith} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
*
* @param other
* a Single to be concatenated after the current
* @return a Flowable that emits the item emitted by the source Single, followed by the item emitted by
* {@code t1}
* @see <a href="http://reactivex.io/documentation/operators/concat.html">ReactiveX operators documentation: Concat</a>
*/
@BackpressureSupport(BackpressureKind.FULL)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<T> concatWith(SingleSource<? extends T> other) {
return concat(this, other);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void concatIterableIteratorNull() {
Single.concat(new Iterable<Single<Object>>() {
@Override
public Iterator<Single<Object>> iterator() {
return null;
}
}).blockingSubscribe();
}
代码示例来源:origin: ReactiveX/RxJava
/**
* Concatenate the single values, in a non-overlapping fashion, of the SingleSources provided by
* a Publisher sequence.
* <p>
* <img width="640" height="308" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Single.concat.p.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The returned {@code Flowable} honors the backpressure of the downstream consumer
* and the sources {@code Publisher} is expected to honor it as well.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code concat} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
* @param <T> the value type
* @param sources the Publisher of SingleSource instances
* @return the new Flowable instance
* @since 2.0
*/
@CheckReturnValue
@NonNull
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Flowable<T> concat(Publisher<? extends SingleSource<? extends T>> sources) {
return concat(sources, 2);
}
代码示例来源:origin: redisson/redisson
/**
* Concatenate the single values, in a non-overlapping fashion, of the Single sources provided by
* a Publisher sequence.
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The returned {@code Flowable} honors the backpressure of the downstream consumer
* and the sources {@code Publisher} is expected to honor it as well.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code concat} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
* @param <T> the value type
* @param sources the Publisher of SingleSource instances
* @return the new Flowable instance
* @since 2.0
*/
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Flowable<T> concat(Publisher<? extends SingleSource<? extends T>> sources) {
return concat(sources, 2);
}
代码示例来源:origin: redisson/redisson
/**
* Returns a Flowable that emits the item emitted by the source Single, then the item emitted by the
* specified Single.
* <p>
* <img width="640" height="335" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Single.concatWith.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The returned {@code Flowable} honors the backpressure of the downstream consumer.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code concatWith} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
*
* @param other
* a Single to be concatenated after the current
* @return a Flowable that emits the item emitted by the source Single, followed by the item emitted by
* {@code t1}
* @see <a href="http://reactivex.io/documentation/operators/concat.html">ReactiveX operators documentation: Concat</a>
*/
@BackpressureSupport(BackpressureKind.FULL)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<T> concatWith(SingleSource<? extends T> other) {
return concat(this, other);
}
代码示例来源:origin: ReactiveX/RxJava
/**
* Concatenate the single values, in a non-overlapping fashion, of the SingleSources provided by
* an Iterable sequence.
* <p>
* <img width="640" height="319" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Single.concat.i.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The returned {@code Flowable} honors the backpressure of the downstream consumer.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code concat} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
* @param <T> the value type
* @param sources the Iterable sequence of SingleSource instances
* @return the new Flowable instance
* @since 2.0
*/
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
@BackpressureSupport(BackpressureKind.FULL)
public static <T> Flowable<T> concat(Iterable<? extends SingleSource<? extends T>> sources) {
return concat(Flowable.fromIterable(sources));
}
代码示例来源:origin: redisson/redisson
/**
* Concatenate the single values, in a non-overlapping fashion, of the Single sources provided by
* an Iterable sequence.
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The returned {@code Flowable} honors the backpressure of the downstream consumer.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code concat} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
* @param <T> the value type
* @param sources the Iterable sequence of SingleSource instances
* @return the new Flowable instance
* @since 2.0
*/
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
@BackpressureSupport(BackpressureKind.FULL)
public static <T> Flowable<T> concat(Iterable<? extends SingleSource<? extends T>> sources) {
return concat(Flowable.fromIterable(sources));
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void callable() {
Single.concat(Flowable.fromCallable(new Callable<Single<Integer>>() {
@Override
public Single<Integer> call() throws Exception {
return Single.just(1);
}
}))
.test()
.assertResult(1);
}
}
代码示例来源:origin: ReactiveX/RxJava
ObjectHelper.requireNonNull(source1, "source1 is null");
ObjectHelper.requireNonNull(source2, "source2 is null");
return concat(Flowable.fromArray(source1, source2));
代码示例来源:origin: ReactiveX/RxJava
@Test
public void scalar() {
Single.concat(Flowable.just(Single.just(1)))
.test()
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void concat2() {
Single.concat(Single.just(1), Single.just(2))
.test()
.assertResult(1, 2);
}
代码示例来源:origin: ReactiveX/RxJava
@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscriptionIterable() {
final int[] calls = { 0 };
Single<Integer> source = Single.create(new SingleOnSubscribe<Integer>() {
@Override
public void subscribe(SingleEmitter<Integer> s) throws Exception {
calls[0]++;
s.onSuccess(1);
}
});
Single.concat(Arrays.asList(source, source)).firstElement()
.test()
.assertResult(1);
assertEquals(1, calls[0]);
}
}
代码示例来源:origin: ReactiveX/RxJava
ObjectHelper.requireNonNull(source2, "source2 is null");
ObjectHelper.requireNonNull(source3, "source3 is null");
return concat(Flowable.fromArray(source1, source2, source3));
代码示例来源:origin: ReactiveX/RxJava
@Test
public void concat3() {
Single.concat(Single.just(1), Single.just(2), Single.just(3))
.test()
.assertResult(1, 2, 3);
}
代码示例来源:origin: ReactiveX/RxJava
@SuppressWarnings("unchecked")
@Test
public void concatObservable() {
for (int i = 1; i < 100; i++) {
Single<Integer>[] array = new Single[i];
Arrays.fill(array, Single.just(1));
Single.concat(Observable.fromArray(array))
.test()
.assertSubscribed()
.assertValueCount(i)
.assertNoErrors()
.assertComplete();
}
}
代码示例来源:origin: ReactiveX/RxJava
ObjectHelper.requireNonNull(source3, "source3 is null");
ObjectHelper.requireNonNull(source4, "source4 is null");
return concat(Flowable.fromArray(source1, source2, source3, source4));
代码示例来源:origin: ReactiveX/RxJava
@Test
public void concat4() {
Single.concat(Single.just(1), Single.just(2), Single.just(3), Single.just(4))
.test()
.assertResult(1, 2, 3, 4);
}
内容来源于网络,如有侵权,请联系作者删除!