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