/** * Merges an Iterable sequence of SingleSource instances into a single Flowable sequence, * running all SingleSources at once and delaying any error(s) until all sources succeed or fail. * <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 mergeDelayError} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * <p>History: 2.1.9 - experimental * @param <T> the common and resulting value type * @param sources the Iterable sequence of SingleSource sources * @return the new Flowable instance * @see #merge(Iterable) * @since 2.2 */ @CheckReturnValue @NonNull @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.NONE) public static <T> Flowable<T> mergeDelayError(Iterable<? extends SingleSource<? extends T>> sources) { return mergeDelayError(Flowable.fromIterable(sources)); }
/** * Merges an Iterable sequence of SingleSource instances into a single Flowable sequence, * running all SingleSources at once and delaying any error(s) until all sources succeed or fail. * <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 mergeDelayError} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * @param <T> the common and resulting value type * @param sources the Iterable sequence of SingleSource sources * @return the new Flowable instance * @since 2.1.9 - experimental * @see #merge(Iterable) */ @CheckReturnValue @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.NONE) @Experimental public static <T> Flowable<T> mergeDelayError(Iterable<? extends SingleSource<? extends T>> sources) { return mergeDelayError(Flowable.fromIterable(sources)); }
@SuppressWarnings("unchecked") @Test public void mergeDelayErrorIterable() { Single.mergeDelayError(Arrays.asList( Single.just(1), Single.<Integer>error(new TestException()), Single.just(2)) ) .test() .assertFailure(TestException.class, 1, 2); }
ObjectHelper.requireNonNull(source1, "source1 is null"); ObjectHelper.requireNonNull(source2, "source2 is null"); return mergeDelayError(Flowable.fromArray(source1, source2));
@Test public void mergeDelayError2() { Single.mergeDelayError( Single.just(1), Single.<Integer>error(new TestException()) ) .test() .assertFailure(TestException.class, 1); }
@Test public void mergeDelayError2ErrorFirst() { Single.mergeDelayError( Single.<Integer>error(new TestException()), Single.just(1) ) .test() .assertFailure(TestException.class, 1); }
ObjectHelper.requireNonNull(source2, "source2 is null"); ObjectHelper.requireNonNull(source3, "source3 is null"); return mergeDelayError(Flowable.fromArray(source1, source2, source3));
@Test public void mergeDelayError3() { Single.mergeDelayError( Single.just(1), Single.<Integer>error(new TestException()), Single.just(2) ) .test() .assertFailure(TestException.class, 1, 2); }
ObjectHelper.requireNonNull(source1, "source1 is null"); ObjectHelper.requireNonNull(source2, "source2 is null"); return mergeDelayError(Flowable.fromArray(source1, source2));
ObjectHelper.requireNonNull(source3, "source3 is null"); ObjectHelper.requireNonNull(source4, "source4 is null"); return mergeDelayError(Flowable.fromArray(source1, source2, source3, source4));
@Test public void mergeDelayErrorPublisher() { Single.mergeDelayError(Flowable.just( Single.just(1), Single.<Integer>error(new TestException()), Single.just(2)) ) .test() .assertFailure(TestException.class, 1, 2); }
@Test public void mergeDelayError4() { Single.mergeDelayError( Single.just(1), Single.<Integer>error(new TestException()), Single.just(2), Single.just(3) ) .test() .assertFailure(TestException.class, 1, 2, 3); } }
ObjectHelper.requireNonNull(source2, "source2 is null"); ObjectHelper.requireNonNull(source3, "source3 is null"); return mergeDelayError(Flowable.fromArray(source1, source2, source3));
ObjectHelper.requireNonNull(source3, "source3 is null"); ObjectHelper.requireNonNull(source4, "source4 is null"); return mergeDelayError(Flowable.fromArray(source1, source2, source3, source4));