本文整理汇总了Java中io.reactivex.Flowable.empty方法的典型用法代码示例。如果您正苦于以下问题:Java Flowable.empty方法的具体用法?Java Flowable.empty怎么用?Java Flowable.empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Flowable
的用法示例。
在下文中一共展示了Flowable.empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cartesian
import io.reactivex.Flowable; //导入方法依赖的package包/类
/**
*
* @author [email protected]
* @param sources
* @return
*/
public static Flowable<int[]> cartesian(List<Flowable<Integer>> sources) {
if (sources.size() == 0) {
return Flowable.empty();
}
Flowable<int[]> main = Flowable.just(new int[0]);
for (int i = 0; i < sources.size(); i++) {
int j = i;
Flowable<Integer> o = sources.get(i).cache();
main = main.<int[]> flatMap(v -> o.map(w -> {
int[] arr = Arrays.copyOf(v, j + 1);
arr[j] = w;
return arr;
}));
}
return main;
}
示例2: getTrivia
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override public Flowable<NumbersTriviaPayload> getTrivia(String commaSeparatedNumbers) {
switch (nextReturn) {
case SUCCESS_200:
return FakeResponses.triviaResults();
case NOT_FOUND_404:
return FakeResponses.notFound();
case INTERNAL_SERVER_ERROR_5xy:
return FakeResponses.internalServerError();
case CONNECTION_ERROR:
return FakeResponses.connectionIssue();
case CONNECTION_TIMEOUT:
return FakeResponses.requestTimeout();
}
return Flowable.empty();
}
示例3: getTask
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<Optional<Task>> getTask(@NonNull String taskId) {
final Task task = TASKS_SERVICE_DATA.get(taskId);
if (task != null) {
return Flowable.just(Optional.of(task)).delay(SERVICE_LATENCY_IN_MILLIS, TimeUnit.MILLISECONDS);
} else {
return Flowable.empty();
}
}
示例4: run
import io.reactivex.Flowable; //导入方法依赖的package包/类
/**
* Start this upload asynchronously. Returns progress updates.
*
* @return {@link Flowable} that emits {@link Progress} events
*/
public Flowable<Progress<FileLink>> run() {
Flowable<Prog<FileLink>> startFlow = Flowable
.fromCallable(new UploadStartFunc(this))
.subscribeOn(Schedulers.io());
// Create multiple func instances to each upload a subrange of parts from the file
// Merge each of these together into one so they're executed concurrently
Flowable<Prog<FileLink>> transferFlow = Flowable.empty();
for (int i = 0; i < CONCURRENCY; i++) {
UploadTransferFunc func = new UploadTransferFunc(this);
Flowable<Prog<FileLink>> temp = Flowable
.create(func, BackpressureStrategy.BUFFER)
.subscribeOn(Schedulers.io());
transferFlow = transferFlow.mergeWith(temp);
}
Flowable<Prog<FileLink>> completeFlow = Flowable
.fromCallable(new UploadCompleteFunc(this))
.subscribeOn(Schedulers.io());
return startFlow
.concatWith(transferFlow)
.concatWith(completeFlow)
.buffer(PROG_INTERVAL_SEC, TimeUnit.SECONDS)
.flatMap(new ProgMapFunc(this));
}
示例5: apply
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Publisher<Progress<FileLink>> apply(List<Prog<FileLink>> progs) throws Exception {
// Skip update if buffer is empty
if (progs.size() == 0) {
return Flowable.empty();
}
int bytes = 0;
FileLink data = null;
for (Prog<FileLink> simple : progs) {
bytes += simple.getBytes();
data = simple.getData();
}
// Bytes could equal 0 if we only have a status from start or complete func
// We don't want to update the rate for requests that don't carry file content
if (bytes != 0) {
bytesSent += bytes;
if (avgRate == 0) {
avgRate = bytes;
} else {
avgRate = Progress.calcAvg(bytes, avgRate);
}
}
// Skip update if we haven't sent anything or are waiting on the complete func
if (bytesSent == 0 || (bytesSent / upload.inputSize == 1 && data == null)) {
return Flowable.empty();
}
long currentTime = System.currentTimeMillis();
int elapsed = (int) ((currentTime - startTime) / 1000L);
double rate = avgRate / Upload.PROG_INTERVAL_SEC; // Want bytes / second not bytes / interval
return Flowable.just(new Progress<>(bytesSent, upload.inputSize, elapsed, rate, data));
}
示例6: testEqualityOfFlatMappedStreamIdOnEqualStreams
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test
public void testEqualityOfFlatMappedStreamIdOnEqualStreams() {
StreamId<Object> sourceStreamId = DUMMY_STREAM_ID_1;
Function<Object, Publisher<Object>> conversion = o -> Flowable.empty();
StreamId<Object> flatMappedStream1 = ComposedStreams.flatMappedStream(sourceStreamId, conversion);
StreamId<Object> flatMappedStream2 = ComposedStreams.flatMappedStream(sourceStreamId, conversion);
assertThat(flatMappedStream1).isEqualTo(flatMappedStream2);
}
示例7: testEqualityOfFlatMappedStreamIdOnNotEqualStreamSources
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test
public void testEqualityOfFlatMappedStreamIdOnNotEqualStreamSources() {
Function<Object, Publisher<Object>> conversion = o -> Flowable.empty();
StreamId<Object> flatMappedStream1 = ComposedStreams.flatMappedStream(DUMMY_STREAM_ID_1, conversion);
StreamId<Object> flatMappedStream2 = ComposedStreams.flatMappedStream(DUMMY_STREAM_ID_2, conversion);
assertThat(flatMappedStream1).isNotEqualTo(flatMappedStream2);
}
示例8: applyAsync
import io.reactivex.Flowable; //导入方法依赖的package包/类
/**
* Overrides the default implementation, to simplify implementing async transforms
* <p/>
* <p/> {@link PollingTransform}s are observed on the specified scheduler
*/
@Override
public Flowable<List<List<Transmutation>>> applyAsync(List<List<Transmutation>> input, Scheduler scheduler) {
// determine if the implementing class should run
if (skipTransform(input)) {
return Flowable.just(input);
}
// remove items that should not be processed
List<List<Transmutation>> toProcess = filter(input);
if (isNull(toProcess)) {
logger.info("Stopping processing in {} due to threshold not met...", this.getClass().getSimpleName());
return Flowable.empty();
}
return Flowable.just(toProcess)
.observeOn(scheduler)
// send payload
.map(this::sendRequest)
.flatMap(req -> tryRetrieve(req, -1))
// or timeout after the specified number of ms
.timeout(timeoutMillis(), TimeUnit.MILLISECONDS)
.doOnError(this::logAsyncError)
.onErrorResumeNext(Flowable.empty());
}
示例9: executeAsync
import io.reactivex.Flowable; //导入方法依赖的package包/类
/**
* Default processor logic that will first filter the required data then process all valid entries
* this method will handle async processing
*
* @return list of results or empty list when nothing was processed
*/
default Flowable<List<List<Transmutation>>> executeAsync(List<Extract> data) {
List<T> filtered = filter(data);
if (!filtered.isEmpty()) {
return processAsync(filtered);
}
return Flowable.empty();
}
示例10: executeAsync
import io.reactivex.Flowable; //导入方法依赖的package包/类
/**
* Default processor logic that will first filter the required data then process all valid entries
* this method will handle async processing
*
* @return list of results or empty list when nothing was processed
*/
default Flowable<List<Boolean>> executeAsync(List<Transmutation> data, List<Load> destinations) {
List<T> filtered = filter(destinations);
if (!filtered.isEmpty()) {
return processAsync(data, filtered);
}
return Flowable.empty();
}
示例11: shouldNotAssignEmpty_WithEmptyFlow
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test public void shouldNotAssignEmpty_WithEmptyFlow() throws Exception {
Flowable<Integer> empty = Flowable.empty();
empty.compose(assignEmptyness).subscribe();
verify(hideEmtpyState, oneTimeOnly()).run();
verify(showEmtpyState, never()).run();
}
示例12: shouldNotAssignError_WithEmptyFlow
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test public void shouldNotAssignError_WithEmptyFlow() throws Exception {
Flowable<String> empty = Flowable.empty();
empty.compose(assignErrorState).subscribe();
verify(hide, oneTimeOnly()).run();
verify(show, never()).run();
}
示例13: testRegistrationOfNamedSource
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test
public void testRegistrationOfNamedSource() {
Source<String> source = new AbstractSource<String>(Flowable.empty()) {
@Override
public String name() {
return "my-source";
}
};
FluidRegistry.register(source);
assertThat(FluidRegistry.source("my-source")).isSameAs(source);
assertThat(FluidRegistry.source("my-source", String.class)).isSameAs(source);
}
示例14: mapEventsToActions
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Function<BaseEvent, Flowable<?>> mapEventsToActions() {
return event -> {
Flowable action = Flowable.empty();
if (event instanceof GetPaginatedUsersEvent) {
action = getUsers(((GetPaginatedUsersEvent) event).getPayLoad());
} else if (event instanceof DeleteUsersEvent) {
action = deleteCollection(((DeleteUsersEvent) event).getPayLoad());
} else if (event instanceof SearchUsersEvent) {
action = search(((SearchUsersEvent) event).getPayLoad());
}
return action;
};
}
示例15: getLastLocation
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<BDLocation> getLastLocation() {
BDLocation location = mClient.getLastKnownLocation();
return location == null ? Flowable.<BDLocation>empty() : Single.just(location).toFlowable();
}