本文整理了Java中rx.Observable.mergeMap()
方法的一些代码示例,展示了Observable.mergeMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.mergeMap()
方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:mergeMap
[英]Returns an Observable that emits the results of applying a specified function to each item emitted by the source Observable, where that function returns an Observable, and then merging those resulting Observables and emitting the results of this merger.
Scheduler: mergeMap does not operate by default on a particular Scheduler.
[中]返回一个Observable,该Observable发出对源Observable发出的每个项应用指定函数的结果,其中该函数返回一个Observable,然后合并这些结果Observable并发出此合并的结果。
调度器:默认情况下,mergeMap不会在特定的调度器上运行。
代码示例来源:origin: com.netflix.rxjava/rxjava-core
/**
* Returns an Observable that emits the results of applying a function to the pair of values from the source
* Observable and an Iterable corresponding to that item that is generated by a selector.
* <p>
* <img width="640" height="390" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mergeMapIterable.r.png" alt="">
* <dl>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code mergeMapIterable} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
*
* @param <U>
* the collection element type
* @param <R>
* the type of item emited by the resulting Observable
* @param collectionSelector
* a function that returns an Iterable sequence of values for each item emitted by the source
* Observable
* @param resultSelector
* a function that returns an item based on the item emitted by the source Observable and the
* Iterable returned for that item by the {@code collectionSelector}
* @return an Observable that emits the items returned by {@code resultSelector} for each item in the source
* Observable
* @see <a href="https://github.com/Netflix/RxJava/wiki/Transforming-Observables#flatmap-concatmap-and-flatmapiterable">RxJava wiki: flatMapIterable</a>
* @deprecated use {@link #flatMapIterable}
*/
@Deprecated
public final <U, R> Observable<R> mergeMapIterable(Func1<? super T, ? extends Iterable<? extends U>> collectionSelector,
Func2<? super T, ? super U, ? extends R> resultSelector) {
return mergeMap(OperatorMapPair.convertSelector(collectionSelector), resultSelector);
}
代码示例来源:origin: OpenNMS/newts
.mergeMap(postJSON(m_restUrl, httpClient))
代码示例来源:origin: OpenNMS/newts
.mergeMap(lines())
.mergeMap(samples())
内容来源于网络,如有侵权,请联系作者删除!