rx.Observable.flatMap()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(13.2k)|赞(0)|评价(0)|浏览(214)

本文整理了Java中rx.Observable.flatMap()方法的一些代码示例,展示了Observable.flatMap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.flatMap()方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:flatMap

Observable.flatMap介绍

[英]Returns an Observable that emits items based on applying a function that you supply 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: flatMap does not operate by default on a particular Scheduler.
[中]返回一个可观测项,该可观测项基于对源可观测项发出的每个项应用一个函数,该函数返回一个可观测项,然后合并这些结果可观测项并发出此合并的结果。
调度程序:默认情况下,flatMap不会在特定调度程序上运行。

代码示例

代码示例来源:origin: hidroh/materialistic

@Override
public void parse(String itemId, String url, Callback callback) {
  Observable.defer(() -> fromCache(itemId))
      .subscribeOn(mIoScheduler)
      .flatMap(content -> content != null ?
          Observable.just(content) : fromNetwork(itemId, url))
      .map(content -> AndroidUtils.TextUtils.equals(EMPTY_CONTENT, content) ? null : content)
      .observeOn(mMainThreadScheduler)
      .subscribe(callback::onResponse);
}

代码示例来源:origin: com.microsoft.azure/azure-mgmt-resources

throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
Validator.validate(parameters);
final String apiVersion = "2017-06-01-preview";
return service.createOrUpdateAtManagementGroup(policySetDefinitionName, managementGroupId, parameters, apiVersion, this.client.acceptLanguage(), this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<PolicySetDefinitionInner>>>() {
    @Override
    public Observable<ServiceResponse<PolicySetDefinitionInner>> call(Response<ResponseBody> response) {

代码示例来源:origin: Azure/azure-libraries-for-java

throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
Validator.validate(parameters);
final String op = "GRANTACE";
String parameterizedHost = Joiner.on(", ").join("{accountName}", accountName, "{adlaCatalogDnsSuffix}", this.client.adlaCatalogDnsSuffix());
return service.grantAclToDatabase(databaseName, parameters, op, this.client.apiVersion(), this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
    @Override
    public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {

代码示例来源:origin: Azure/azure-libraries-for-java

throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
String parameterizedHost = Joiner.on(", ").join("{accountName}", accountName, "{adlaCatalogDnsSuffix}", this.client.adlaCatalogDnsSuffix());
return service.deleteSecret(databaseName, secretName, this.client.apiVersion(), this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
    @Override
    public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {

代码示例来源:origin: Azure/azure-libraries-for-java

throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
String parameterizedHost = Joiner.on(", ").join("{accountName}", accountName, "{adlaCatalogDnsSuffix}", this.client.adlaCatalogDnsSuffix());
return service.getCredential(databaseName, credentialName, this.client.apiVersion(), this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<USqlCredential>>>() {
    @Override
    public Observable<ServiceResponse<USqlCredential>> call(Response<ResponseBody> response) {

代码示例来源:origin: Azure/azure-libraries-for-java

throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
Validator.validate(parameters);
String parameterizedHost = Joiner.on(", ").join("{accountName}", accountName, "{adlaJobDnsSuffix}", this.client.adlaJobDnsSuffix());
return service.beginUpdate(jobIdentity, parameters, this.client.apiVersion(), this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<JobInformation>>>() {
    @Override
    public Observable<ServiceResponse<JobInformation>> call(Response<ResponseBody> response) {

代码示例来源:origin: PipelineAI/pipeline

protected RollingConcurrencyStream(final HystrixEventStream<HystrixCommandExecutionStarted> inputEventStream, final int numBuckets, final int bucketSizeInMs) {
  final List<Integer> emptyRollingMaxBuckets = new ArrayList<Integer>();
  for (int i = 0; i < numBuckets; i++) {
    emptyRollingMaxBuckets.add(0);
  }
  rollingMaxStream = inputEventStream
      .observe()
      .map(getConcurrencyCountFromEvent)
      .window(bucketSizeInMs, TimeUnit.MILLISECONDS)
      .flatMap(reduceStreamToMax)
      .startWith(emptyRollingMaxBuckets)
      .window(numBuckets, 1)
      .flatMap(reduceStreamToMax)
      .share()
      .onBackpressureDrop();
}

代码示例来源:origin: com.microsoft.azure/azure-mgmt-resources

throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
Validator.validate(parameters);
return service.beginCreateOrUpdateById(resourceId, apiVersion, parameters, this.client.acceptLanguage(), this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<GenericResourceInner>>>() {
    @Override
    public Observable<ServiceResponse<GenericResourceInner>> call(Response<ResponseBody> response) {

代码示例来源:origin: Azure/azure-libraries-for-java

throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
String parameterizedHost = Joiner.on(", ").join("{accountName}", accountName, "{adlaCatalogDnsSuffix}", this.client.adlaCatalogDnsSuffix());
return service.getAssembly(databaseName, assemblyName, this.client.apiVersion(), this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<USqlAssembly>>>() {
    @Override
    public Observable<ServiceResponse<USqlAssembly>> call(Response<ResponseBody> response) {

代码示例来源:origin: Azure/azure-libraries-for-java

throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
Validator.validate(parameters);
final String op = "REVOKEACE";
String parameterizedHost = Joiner.on(", ").join("{accountName}", accountName, "{adlaCatalogDnsSuffix}", this.client.adlaCatalogDnsSuffix());
return service.revokeAclFromDatabase(databaseName, parameters, op, this.client.apiVersion(), this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
    @Override
    public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {

代码示例来源:origin: apache/usergrid

public Observable<CollectionIoEvent<MvccEntity>> stageRunner( CollectionIoEvent<Entity> writeData,
                               WriteStart writeState ) {
  return Observable.just( writeData ).map( writeState ).flatMap( mvccEntityCollectionIoEvent -> {
    Observable<CollectionIoEvent<MvccEntity>> uniqueObservable =
      Observable.just( mvccEntityCollectionIoEvent ).subscribeOn( rxTaskScheduler.getAsyncIOScheduler() )
        .doOnNext( writeVerifyUnique );
    // optimistic verification
    Observable<CollectionIoEvent<MvccEntity>> optimisticObservable =
      Observable.just( mvccEntityCollectionIoEvent ).subscribeOn( rxTaskScheduler.getAsyncIOScheduler() )
        .doOnNext( writeOptimisticVerify );
    final Observable<CollectionIoEvent<MvccEntity>> zip =
      Observable.zip( uniqueObservable, optimisticObservable, ( unique, optimistic ) -> optimistic );
    return zip;
  } );
}

代码示例来源:origin: com.microsoft.azure.resources.v2018_02_01/azure-mgmt-resources

throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
Validator.validate(parameters);
return service.beginUpdateById(resourceId, apiVersion, parameters, this.client.acceptLanguage(), this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<GenericResourceInner>>>() {
    @Override
    public Observable<ServiceResponse<GenericResourceInner>> call(Response<ResponseBody> response) {

代码示例来源:origin: Azure/azure-libraries-for-java

throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
String parameterizedHost = Joiner.on(", ").join("{accountName}", accountName, "{adlaCatalogDnsSuffix}", this.client.adlaCatalogDnsSuffix());
return service.getSchema(databaseName, schemaName, this.client.apiVersion(), this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<USqlSchema>>>() {
    @Override
    public Observable<ServiceResponse<USqlSchema>> call(Response<ResponseBody> response) {

代码示例来源:origin: Azure/azure-libraries-for-java

throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
Validator.validate(parameters);
String parameterizedHost = Joiner.on(", ").join("{accountName}", accountName, "{adlaJobDnsSuffix}", this.client.adlaJobDnsSuffix());
return service.build(parameters, this.client.apiVersion(), this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<JobInformation>>>() {
    @Override
    public Observable<ServiceResponse<JobInformation>> call(Response<ResponseBody> response) {

代码示例来源:origin: HotBitmapGG/bilibili-android-client

.getLiveUrl(cid)
.compose(this.bindToLifecycle())
.map(responseBody -> {
  try {
    String str = responseBody.string();
.flatMap(new Func1<String, Observable<Long>>() {
  @Override
  public Observable<Long> call(String s) {

代码示例来源:origin: com.microsoft.azure/azure-mgmt-resources

throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
Validator.validate(parameters);
final String apiVersion = "2016-12-01";
return service.createOrUpdateAtManagementGroup(policyDefinitionName, managementGroupId, parameters, apiVersion, this.client.acceptLanguage(), this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<PolicyDefinitionInner>>>() {
    @Override
    public Observable<ServiceResponse<PolicyDefinitionInner>> call(Response<ResponseBody> response) {

代码示例来源:origin: Azure/azure-libraries-for-java

throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
String parameterizedHost = Joiner.on(", ").join("{accountName}", accountName, "{adlaCatalogDnsSuffix}", this.client.adlaCatalogDnsSuffix());
return service.getSecret(databaseName, secretName, this.client.apiVersion(), this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<USqlSecret>>>() {
    @Override
    public Observable<ServiceResponse<USqlSecret>> call(Response<ResponseBody> response) {

代码示例来源:origin: Azure/azure-libraries-for-java

throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
Validator.validate(parameters);
final String op = "GRANTACE";
String parameterizedHost = Joiner.on(", ").join("{accountName}", accountName, "{adlaCatalogDnsSuffix}", this.client.adlaCatalogDnsSuffix());
return service.grantAcl(parameters, op, this.client.apiVersion(), this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
    @Override
    public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {

代码示例来源:origin: apache/usergrid

@Override
public Observable<MarkedEdge> compactNode( final Id inputNode ) {
  final UUID startTime = UUIDGenerator.newTimeUUID();
  final Observable<MarkedEdge> nodeObservable =
    Observable.just( inputNode )
      .map( node -> nodeSerialization.getMaxVersion( scope, node ) )
      //.doOnNext(maxTimestamp -> logger.info("compactNode maxTimestamp={}", maxTimestamp.toString()))
      .takeWhile(maxTimestamp -> maxTimestamp.isPresent() )
      //map our delete listener
      .flatMap( timestamp -> nodeDeleteListener.receive( scope, inputNode, startTime ) );
  return ObservableTimer.time( nodeObservable, this.deleteNodeTimer );
}

代码示例来源:origin: com.microsoft.azure/azure-mgmt-resources

throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
Validator.validate(parameters);
return service.beginUpdateById(resourceId, apiVersion, parameters, this.client.acceptLanguage(), this.client.userAgent())
  .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<GenericResourceInner>>>() {
    @Override
    public Observable<ServiceResponse<GenericResourceInner>> call(Response<ResponseBody> response) {

相关文章

Observable类方法