本文整理汇总了Java中io.reactivex.Flowable.merge方法的典型用法代码示例。如果您正苦于以下问题:Java Flowable.merge方法的具体用法?Java Flowable.merge怎么用?Java Flowable.merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Flowable
的用法示例。
在下文中一共展示了Flowable.merge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test2
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test
public void test2() {
Flowable<Long> trigger = Flowable
.merge(asList(delayed(500), delayed(3500), delayed(4500), delayed(6500), delayed(8500)));
Flowable<Long> data = Flowable.interval(1000, MILLISECONDS);
subscribeAndWait(data, trigger);
assertThat(subscriber.values()).containsExactly(2L, 3L, 5L, 7L);
}
示例2: mergeWith
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
@SafeVarargs
public final DataStream<T> mergeWith(DataStream<T>... streams) {
Objects.requireNonNull(streams, NULL_STREAMS_MESSAGE);
List<DataStream<T>> list = new ArrayList<>();
list.add(this);
list.addAll(Arrays.asList(streams));
Flowable<Data<T>> merged = Flowable.merge(list.stream()
.map(DataStream::flow)
.collect(Collectors.toList())
);
List<DataStream> previous = new ArrayList<>();
previous.add(this);
previous.addAll(Arrays.asList(streams));
DataStreamImpl<Object, T> next = new DataStreamImpl<>(previous, merged);
this.setDownstreams(next);
Arrays.stream(streams).forEach(d -> d.setDownstreams(next));
return next;
}
示例3: mergedStream
import io.reactivex.Flowable; //导入方法依赖的package包/类
/**
* EXPERIMENTAL Creates a {@link StreamId} that will be used to create a {@link org.reactivestreams.Publisher} which
* will emit all the items emitted by the {@link org.reactivestreams.Publisher}s identified by the provided
* {@link StreamId}s.
*
* @param sourceStreamIds {@link List} of {@link StreamId}s which identify {@link org.reactivestreams.Publisher}s
* that will be used as the source of the new {@link org.reactivestreams.Publisher}.
* @return A {@link StreamId}.
* @throws IllegalArgumentException If the provided list of source stream ids is null or empty.
* @see Flowable#merge(Iterable)
*/
public static final <X> StreamId<X> mergedStream(final List<StreamId<X>> sourceStreamIds) {
checkCollectionAndThrow(sourceStreamIds, "sourceStreamIds");
return new CompositionStreamId<>(sourceStreamIds, reactiveStreams -> {
List<Flowable<X>> observablesToMerge = new ArrayList<>();
for (Publisher<X> reactiveStream : reactiveStreams) {
observablesToMerge.add(Flowable.fromPublisher(reactiveStream));
}
return Flowable.merge(observablesToMerge);
});
}
示例4: flowEach
import io.reactivex.Flowable; //导入方法依赖的package包/类
/**
* @param promise
* @param strategy The {@link BackpressureStrategy} to use
* @param <T>
* @param <I>
* @return
* @see RxRatpack#observeEach(Promise)
*/
public static <T, I extends Iterable<T>> Flowable<T> flowEach(Promise<I> promise, BackpressureStrategy strategy) {
return Flowable.merge(flow(promise, strategy).map(Flowable::fromIterable));
}