当前位置: 首页>>代码示例>>Java>>正文


Java Flowable.using方法代码示例

本文整理汇总了Java中io.reactivex.Flowable.using方法的典型用法代码示例。如果您正苦于以下问题:Java Flowable.using方法的具体用法?Java Flowable.using怎么用?Java Flowable.using使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.reactivex.Flowable的用法示例。


在下文中一共展示了Flowable.using方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: forFlowable

import io.reactivex.Flowable; //导入方法依赖的package包/类
private <T> Flowable<T> forFlowable(Flowable<T> source, BackpressureStrategy backpressureStrategy) {
    return Flowable.using(this::makeDialog,
            new Function<ProgressDialog, Publisher<? extends T>>() {
                @Override
                public Publisher<? extends T> apply(@NonNull ProgressDialog dialog) throws Exception {
                    return Flowable.create(emitter -> {
                        if (builder.cancelable) {
                            dialog.setOnCancelListener(dialogInterface -> emitter.onComplete());
                        }
                        dialog.setOnDismissListener(dialogInterface -> emitter.onComplete());
                        source.subscribe(emitter::onNext, emitter::onError, emitter::onComplete);
                    }, backpressureStrategy);
                }
            }, Dialog::dismiss);
}
 
开发者ID:datalink747,项目名称:RxProgress,代码行数:16,代码来源:RxProgress.java

示例2: messages

import io.reactivex.Flowable; //导入方法依赖的package包/类
static Flowable<SqsMessage> messages(Callable<AmazonSQS> sqsFactory, Optional<Callable<AmazonS3>> s3Factory,
        String queueName, Optional<String> bucketName, Optional<Flowable<Integer>> waitTimesSeconds) {
    Preconditions.checkNotNull(sqsFactory);
    Preconditions.checkNotNull(s3Factory);
    Preconditions.checkNotNull(queueName);
    Preconditions.checkNotNull(bucketName);
    Preconditions.checkNotNull(waitTimesSeconds);
    return Flowable.using(sqsFactory,
            sqs -> createObservableWithSqs(sqs, s3Factory, sqsFactory, queueName, bucketName, waitTimesSeconds),
            sqs -> sqs.shutdown());
}
 
开发者ID:davidmoten,项目名称:rxjava2-aws,代码行数:12,代码来源:Sqs.java

示例3: createObservableWithSqs

import io.reactivex.Flowable; //导入方法依赖的package包/类
private static Flowable<SqsMessage> createObservableWithSqs(AmazonSQS sqs, Optional<Callable<AmazonS3>> s3Factory,
        Callable<AmazonSQS> sqsFactory, String queueName, Optional<String> bucketName,
        Optional<Flowable<Integer>> waitTimesSeconds) {

    return Flowable.using(() -> s3Factory.map(x -> {
        try {
            return x.call();
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
    }), //
            s3 -> createObservableWithS3(sqs, s3Factory, sqsFactory, queueName, bucketName, s3, waitTimesSeconds),
            s3 -> s3.ifPresent(Util::shutdown));
}
 
开发者ID:davidmoten,项目名称:rxjava2-aws,代码行数:15,代码来源:Sqs.java

示例4: forFlowable

import io.reactivex.Flowable; //导入方法依赖的package包/类
private <T> Flowable<T> forFlowable(Flowable<T> source, BackpressureStrategy backpressureStrategy) {
  return Flowable.using(this::makeDialog,
      new Function<ProgressDialog, Publisher<? extends T>>() {
        @Override
        public Publisher<? extends T> apply(@NonNull ProgressDialog dialog) throws Exception {
          return Flowable.create(emitter -> {
            if (builder.cancelable) {
              dialog.setOnCancelListener(dialogInterface -> emitter.onComplete());
            }
            dialog.setOnDismissListener(dialogInterface -> emitter.onComplete());
            source.subscribe(emitter::onNext, emitter::onError, emitter::onComplete);
          }, backpressureStrategy);
        }
      }, Dialog::dismiss);
}
 
开发者ID:tranngoclam,项目名称:rx-progress-dialog,代码行数:16,代码来源:RxProgressDialog.java


注:本文中的io.reactivex.Flowable.using方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。