本文整理了Java中io.reactivex.Flowable.concatArray()
方法的一些代码示例,展示了Flowable.concatArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flowable.concatArray()
方法的具体详情如下:
包路径:io.reactivex.Flowable
类名称:Flowable
方法名:concatArray
[英]Concatenates a variable number of Publisher sources.
Note: named this way because of overload conflict with concat(Publisher<Publisher>).
Backpressure: The operator honors backpressure from downstream. The Publishersources are expected to honor backpressure as well. If any of the source Publishers violate this, it may throw an IllegalStateException when the source Publisher completes. Scheduler: concatArray does not operate by default on a particular Scheduler.
[中]连接数量可变的发布服务器源。
注意:以这种方式命名是因为与concat(Publisher<Publisher>)的重载冲突。
背压:操作员接受来自下游的背压。预计出版商资源也将承受背压。如果任何源发布服务器违反此规则,则在源发布服务器完成时,它可能抛出非法状态异常。调度程序:默认情况下,concatArray不会在特定调度程序上运行。
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void concatArrayNull() {
Flowable.concatArray((Publisher<Object>[])null);
}
代码示例来源:origin: ReactiveX/RxJava
@SuppressWarnings("unchecked")
@Test(expected = NullPointerException.class)
public void concatArrayOneIsNull() {
Flowable.concatArray(just1, null).blockingLast();
}
代码示例来源:origin: ReactiveX/RxJava
/**
* Returns a Flowable that emits the items in a specified {@link Iterable} before it begins to emit items
* emitted by the source Publisher.
* <p>
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/startWith.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator honors backpressure from downstream. The source {@code Publisher}
* is expected to honor backpressure as well. If it violates this rule, it <em>may</em> throw an
* {@code IllegalStateException} when the source {@code Publisher} completes.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code startWith} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
*
* @param items
* an Iterable that contains the items you want the modified Publisher to emit first
* @return a Flowable that emits the items in the specified {@link Iterable} and then emits the items
* emitted by the source Publisher
* @see <a href="http://reactivex.io/documentation/operators/startwith.html">ReactiveX operators documentation: StartWith</a>
*/
@SuppressWarnings("unchecked")
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<T> startWith(Iterable<? extends T> items) {
return concatArray(fromIterable(items), this);
}
代码示例来源:origin: ReactiveX/RxJava
@SuppressWarnings("unchecked")
@Test
public void concatArrayEmpty() {
assertSame(Flowable.empty(), Flowable.concatArray());
}
代码示例来源:origin: ReactiveX/RxJava
/**
* Returns a Flowable that emits the items in a specified {@link Publisher} before it begins to emit
* items emitted by the source Publisher.
* <p>
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/startWith.o.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator honors backpressure from downstream. Both this and the {@code other} {@code Publisher}s
* are expected to honor backpressure as well. If any of then violates this rule, it <em>may</em> throw an
* {@code IllegalStateException} when the source {@code Publisher} completes.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code startWith} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
*
* @param other
* a Publisher that contains the items you want the modified Publisher to emit first
* @return a Flowable that emits the items in the specified {@link Publisher} and then emits the items
* emitted by the source Publisher
* @see <a href="http://reactivex.io/documentation/operators/startwith.html">ReactiveX operators documentation: StartWith</a>
*/
@SuppressWarnings("unchecked")
@CheckReturnValue
@NonNull
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<T> startWith(Publisher<? extends T> other) {
ObjectHelper.requireNonNull(other, "other is null");
return concatArray(other, this);
}
代码示例来源:origin: redisson/redisson
/**
* Returns a Flowable that emits the items in a specified {@link Iterable} before it begins to emit items
* emitted by the source Publisher.
* <p>
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/startWith.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator honors backpressure from downstream. The source {@code Publisher}
* is expected to honor backpressure as well. If it violates this rule, it <em>may</em> throw an
* {@code IllegalStateException} when the source {@code Publisher} completes.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code startWith} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
*
* @param items
* an Iterable that contains the items you want the modified Publisher to emit first
* @return a Flowable that emits the items in the specified {@link Iterable} and then emits the items
* emitted by the source Publisher
* @see <a href="http://reactivex.io/documentation/operators/startwith.html">ReactiveX operators documentation: StartWith</a>
*/
@SuppressWarnings("unchecked")
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<T> startWith(Iterable<? extends T> items) {
return concatArray(fromIterable(items), this);
}
代码示例来源:origin: redisson/redisson
/**
* Returns a Flowable that emits the items in a specified {@link Publisher} before it begins to emit
* items emitted by the source Publisher.
* <p>
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/startWith.o.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator honors backpressure from downstream. Both this and the {@code other} {@code Publisher}s
* are expected to honor backpressure as well. If any of then violates this rule, it <em>may</em> throw an
* {@code IllegalStateException} when the source {@code Publisher} completes.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code startWith} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
*
* @param other
* a Publisher that contains the items you want the modified Publisher to emit first
* @return a Flowable that emits the items in the specified {@link Publisher} and then emits the items
* emitted by the source Publisher
* @see <a href="http://reactivex.io/documentation/operators/startwith.html">ReactiveX operators documentation: StartWith</a>
*/
@SuppressWarnings("unchecked")
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<T> startWith(Publisher<? extends T> other) {
ObjectHelper.requireNonNull(other, "other is null");
return concatArray(other, this);
}
代码示例来源:origin: ReactiveX/RxJava
@SuppressWarnings("unchecked")
@Test
public void noCancelPreviousArray() {
final AtomicInteger counter = new AtomicInteger();
Flowable<Integer> source = Flowable.just(1).doOnCancel(new Action() {
@Override
public void run() throws Exception {
counter.getAndIncrement();
}
});
Flowable.concatArray(source, source, source, source, source)
.test()
.assertResult(1, 1, 1, 1, 1);
assertEquals(0, counter.get());
}
代码示例来源:origin: ReactiveX/RxJava
@SuppressWarnings("unchecked")
@Test
public void concatArraySingleElement() {
assertSame(Flowable.never(), Flowable.concatArray(Flowable.never()));
}
代码示例来源:origin: ReactiveX/RxJava
/**
* Returns a Flowable that emits a specified item before it begins to emit items emitted by the source
* Publisher.
* <p>
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/startWith.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator honors backpressure from downstream. The source {@code Publisher}
* is expected to honor backpressure as well. If it violates this rule, it <em>may</em> throw an
* {@code IllegalStateException} when the source {@code Publisher} completes.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code startWith} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
*
* @param value
* the item to emit first
* @return a Flowable that emits the specified item before it begins to emit items emitted by the source
* Publisher
* @see <a href="http://reactivex.io/documentation/operators/startwith.html">ReactiveX operators documentation: StartWith</a>
*/
@SuppressWarnings("unchecked")
@CheckReturnValue
@NonNull
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<T> startWith(T value) {
ObjectHelper.requireNonNull(value, "item is null");
return concatArray(just(value), this);
}
代码示例来源:origin: ReactiveX/RxJava
return RxJavaPlugins.onAssembly(this);
return concatArray(fromArray, this);
代码示例来源:origin: ReactiveX/RxJava
ObjectHelper.requireNonNull(source1, "source1 is null");
ObjectHelper.requireNonNull(source2, "source2 is null");
return concatArray(source1, source2);
代码示例来源:origin: redisson/redisson
/**
* Returns a Flowable that emits a specified item before it begins to emit items emitted by the source
* Publisher.
* <p>
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/startWith.png" alt="">
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator honors backpressure from downstream. The source {@code Publisher}
* is expected to honor backpressure as well. If it violates this rule, it <em>may</em> throw an
* {@code IllegalStateException} when the source {@code Publisher} completes.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code startWith} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
*
* @param value
* the item to emit first
* @return a Flowable that emits the specified item before it begins to emit items emitted by the source
* Publisher
* @see <a href="http://reactivex.io/documentation/operators/startwith.html">ReactiveX operators documentation: StartWith</a>
*/
@SuppressWarnings("unchecked")
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<T> startWith(T value) {
ObjectHelper.requireNonNull(value, "item is null");
return concatArray(just(value), this);
}
代码示例来源:origin: redisson/redisson
ObjectHelper.requireNonNull(source1, "source1 is null");
ObjectHelper.requireNonNull(source2, "source2 is null");
return concatArray(source1, source2);
代码示例来源:origin: ReactiveX/RxJava
ObjectHelper.requireNonNull(source2, "source2 is null");
ObjectHelper.requireNonNull(source3, "source3 is null");
return concatArray(source1, source2, source3);
代码示例来源:origin: redisson/redisson
return RxJavaPlugins.onAssembly(this);
return concatArray(fromArray, this);
代码示例来源:origin: ReactiveX/RxJava
ObjectHelper.requireNonNull(source3, "source3 is null");
ObjectHelper.requireNonNull(source4, "source4 is null");
return concatArray(source1, source2, source3, source4);
代码示例来源:origin: redisson/redisson
ObjectHelper.requireNonNull(source2, "source2 is null");
ObjectHelper.requireNonNull(source3, "source3 is null");
return concatArray(source1, source2, source3);
代码示例来源:origin: ReactiveX/RxJava
@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscription() {
final int[] calls = { 0 };
Flowable<Integer> source = Flowable.create(new FlowableOnSubscribe<Integer>() {
@Override
public void subscribe(FlowableEmitter<Integer> s) throws Exception {
calls[0]++;
s.onNext(1);
s.onComplete();
}
}, BackpressureStrategy.MISSING);
Flowable.concatArray(source, source).firstElement()
.test()
.assertResult(1);
assertEquals(1, calls[0]);
}
代码示例来源:origin: redisson/redisson
ObjectHelper.requireNonNull(source3, "source3 is null");
ObjectHelper.requireNonNull(source4, "source4 is null");
return concatArray(source1, source2, source3, source4);
内容来源于网络,如有侵权,请联系作者删除!