本文整理汇总了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);
}
示例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());
}
示例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));
}
示例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);
}