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


Java Flowable.error方法代码示例

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


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

示例1: manyToMany

import io.reactivex.Flowable; //导入方法依赖的package包/类
/**
 * Implements a bidirectional stream -> stream call as {@link Flowable} -> {@link Flowable}, where both the client
 * and the server independently stream to each other.
 */
public static <TRequest, TResponse> Flowable<TResponse> manyToMany(
        Flowable<TRequest> rxRequest,
        Function<StreamObserver<TResponse>, StreamObserver<TRequest>> delegate) {
    try {
        final RxProducerConsumerStreamObserver<TRequest, TResponse> consumerStreamObserver = new RxProducerConsumerStreamObserver<TRequest, TResponse>(rxRequest);
        delegate.apply(new CancellableStreamObserver<TRequest, TResponse>(consumerStreamObserver, new Runnable() {
            @Override
            public void run() {
                consumerStreamObserver.cancel();
            }
        }));
        consumerStreamObserver.rxSubscribe();
        return ((Flowable<TResponse>) consumerStreamObserver.getRxConsumer())
                .lift(new SubscribeOnlyOnceFlowableOperator<TResponse>());
    } catch (Throwable throwable) {
        return Flowable.error(throwable);
    }
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:23,代码来源:ClientCalls.java

示例2: deleteAll

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<Integer> deleteAll() {
    if(shouldThrowError){
        shouldThrowError = false; // special case because the StoreService needs to call again getAll()
        return Flowable.error(new Exception("deleteAll.error"));
    }

    return getAll(null, null)
            .delay(1, TimeUnit.SECONDS)
            .flatMap(new Function<Optional<List<TestModel>>, Flowable<Integer>>() {
                @Override
                public Flowable<Integer> apply(Optional<List<TestModel>> ts) throws Exception {
                    return Flowable.just(ts.get().size());
                }
            });
}
 
开发者ID:playmoweb,项目名称:store2store,代码行数:17,代码来源:TestStore.java

示例3: shouldDisableAfter_WithSpecialError

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test public void shouldDisableAfter_WithSpecialError() throws Exception {
    Flowable<Integer> broken = Flowable.error(new UnexpectedResponseError("Server down"));

    broken.compose(toogler)
            .subscribe(
                    some -> {},
                    Throwable::printStackTrace,
                    () -> {}
            );

    checkForDisableFirstNotEnableAfter();

}
 
开发者ID:ubiratansoares,项目名称:reactive-architectures-playground,代码行数:14,代码来源:ToogleRefreshTests.java

示例4: shouldCoordinateLoading_WithErrorAtFlow

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test public void shouldCoordinateLoading_WithErrorAtFlow() throws Exception {
    Flowable<String> broken = Flowable.error(new RuntimeException("WTF!!"));

    broken.compose(loadingCoordination)
            .subscribe(
                    some -> {},
                    Throwable::printStackTrace,
                    () -> {}
            );

    checkLoadingCoordinated();
}
 
开发者ID:ubiratansoares,项目名称:reactive-architectures-playground,代码行数:13,代码来源:LoadingCoordinationTests.java

示例5: update

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<Optional<List<TestModel>>> update(List<TestModel> items) {
    if(shouldThrowError){
        return Flowable.error(new Exception("update.error"));
    }
    return Flowable.just(Optional.wrap(items)).delay(1, TimeUnit.SECONDS);
}
 
开发者ID:playmoweb,项目名称:store2store,代码行数:8,代码来源:TestStore.java

示例6: insert

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<Optional<TestModel>> insert(TestModel item) {
    if(shouldThrowError){
        return Flowable.error(new Exception("insertSingle.error"));
    }
    return Flowable.just(Optional.wrap(item)).delay(1, TimeUnit.SECONDS);
}
 
开发者ID:playmoweb,项目名称:store2store,代码行数:8,代码来源:TestStore.java

示例7: delete

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<Integer> delete(List<TestModel> items) {
    if(shouldThrowError){
        return Flowable.error(new Exception("delete.error"));
    }
    return Flowable.just(items.size()).delay(1, TimeUnit.SECONDS);
}
 
开发者ID:playmoweb,项目名称:store2store,代码行数:8,代码来源:TestStore.java

示例8: shouldNotHandle_OtherErrors

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test public void shouldNotHandle_OtherErrors() {

        NullPointerException npe = new NullPointerException();
        Flowable<String> otherIssue = Flowable.error(npe);

        otherIssue.compose(handler)
                .test()
                .assertError(throwable -> throwable.equals(npe));
    }
 
开发者ID:ubiratansoares,项目名称:reactive-architectures-playground,代码行数:10,代码来源:RestErrorsHandlerTests.java

示例9: shouldAssignError_WithErrorAtFlow

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test public void shouldAssignError_WithErrorAtFlow() throws Exception {
    Flowable<String> broken = Flowable.error(new RuntimeException("WTF!!"));

    broken.compose(assignErrorState)
            .subscribe(
                    some -> {},
                    Throwable::printStackTrace,
                    () -> {}
            );

    verify(hide, oneTimeOnly()).run();
    verify(show, oneTimeOnly()).run();
}
 
开发者ID:ubiratansoares,项目名称:reactive-architectures-playground,代码行数:14,代码来源:AssignErrorStateTests.java

示例10: handleIfRestError

import io.reactivex.Flowable; //导入方法依赖的package包/类
private Publisher<T> handleIfRestError(Throwable throwable) {

        if (otherThanNotFound(throwable)) {
            return Flowable.error(new UnexpectedResponseError("Undesired response for this call"));
        }

        if (notFound(throwable)) {
            return Flowable.error(new ContentNotFoundError());
        }

        return Flowable.error(throwable);
    }
 
开发者ID:ubiratansoares,项目名称:reactive-architectures-playground,代码行数:13,代码来源:RestErrorsHandler.java

示例11: shouldEnableAfter_WhenNoSpecialError

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test public void shouldEnableAfter_WhenNoSpecialError() throws Exception {
    Flowable<Integer> broken = Flowable.error(new RuntimeException("WTF!!"));

    broken.compose(toogler)
            .subscribe(
                    some -> {},
                    Throwable::printStackTrace,
                    () -> {}
            );

    checkForDisableFirstEnableAfter();
}
 
开发者ID:ubiratansoares,项目名称:reactive-architectures-playground,代码行数:13,代码来源:ToogleRefreshTests.java

示例12: queryConfigFlowable

import io.reactivex.Flowable; //导入方法依赖的package包/类
private synchronized Flowable<VectorTileConfig> queryConfigFlowable() {
  final URL url = Resources.getResource("metadata_raw.sql");
  String query;
  try {
    query = Resources.toString(url, Charsets.UTF_8);
  } catch (final IOException ex) {
    return Flowable.error(ex);
  }
  return dataSource.select(query)
      .get(rs -> new VectorTileConfig(rs.getInt("min_zoom"), rs.getInt("max_zoom"),
          rs.getInt("max_zoom_minx"), rs.getInt("max_zoom_miny"), rs.getInt("max_zoom_maxx"),
          rs.getInt("max_zoom_maxy")));
}
 
开发者ID:OrdnanceSurvey,项目名称:vt-support,代码行数:14,代码来源:StorageImpl.java

示例13: shouldNotAssignEmpty_WithNotTargetError

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test public void shouldNotAssignEmpty_WithNotTargetError() throws Exception {
    Flowable<Integer> broken = Flowable.error(new RuntimeException("WTF!!"));

    broken.compose(assignEmptyness)
            .subscribe(
                    some -> {},
                    Throwable::printStackTrace,
                    () -> {}
            );

    verify(hideEmtpyState, oneTimeOnly()).run();
    verify(showEmtpyState, never()).run();
}
 
开发者ID:ubiratansoares,项目名称:reactive-architectures-playground,代码行数:14,代码来源:AssignEmptyStateTests.java

示例14: apply

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<T> apply(Throwable throwable) throws Exception {
    return Flowable.error(handleException() == null ? ExceptionEngine.handleException(throwable) : handleException());
}
 
开发者ID:fodroid,项目名称:XDroid-Databinding,代码行数:5,代码来源:ServerResultErrorFunc2.java

示例15: shouldHandle_NoInternetAvailable

import io.reactivex.Flowable; //导入方法依赖的package包/类
@Test public void shouldHandle_NoInternetAvailable() {
    Flowable<?> noInternet = Flowable.error(new UnknownHostException("No Internet"));
    noInternet.compose(handler)
            .test()
            .assertError(NetworkingError.class);
}
 
开发者ID:ubiratansoares,项目名称:reactive-architectures-playground,代码行数:7,代码来源:NetworkingErrorHandlerTests.java


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