本文整理汇总了Java中rx.plugins.RxJavaHooks类的典型用法代码示例。如果您正苦于以下问题:Java RxJavaHooks类的具体用法?Java RxJavaHooks怎么用?Java RxJavaHooks使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RxJavaHooks类属于rx.plugins包,在下文中一共展示了RxJavaHooks类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onNext
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
@Override
public void onNext(Response<R> response) {
if (response.isSuccessful()) {
subscriber.onNext(response.body());
} else {
subscriberTerminated = true;
Throwable t = new HttpException(response);
try {
subscriber.onError(t);
} catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
RxJavaHooks.getOnError().call(e);
} catch (Throwable inner) {
Exceptions.throwIfFatal(inner);
RxJavaHooks.getOnError().call(new CompositeException(t, inner));
}
}
}
示例2: onError
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
@Override
public void onError(Throwable throwable) {
try {
subscriber.onNext(Result.<R>error(throwable));
} catch (Throwable t) {
try {
subscriber.onError(t);
} catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
RxJavaHooks.getOnError().call(e);
} catch (Throwable inner) {
Exceptions.throwIfFatal(inner);
RxJavaHooks.getOnError().call(new CompositeException(t, inner));
}
return;
}
subscriber.onCompleted();
}
示例3: setupHooks
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
private void setupHooks() {
RxJavaHooks.setOnObservableStart((observable, onSubscribe) -> {
incrementActiveSubscriptionsCount();
return onSubscribe;
});
RxJavaHooks.setOnObservableSubscribeError(throwable -> {
decrementActiveSubscriptionsCount();
return throwable;
});
RxJavaHooks.setOnObservableReturn(subscription -> {
decrementActiveSubscriptionsCount();
return subscription;
});
}
示例4: apply
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxAndroidPlugins.getInstance().reset();
RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
RxJavaHooks.reset();
RxJavaHooks.setOnIOScheduler(mRxJavaImmediateScheduler);
RxJavaHooks.setOnNewThreadScheduler(mRxJavaImmediateScheduler);
base.evaluate();
RxAndroidPlugins.getInstance().reset();
RxJavaHooks.reset();
}
};
}
示例5: start
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
public Single<Void> start(JsonObject defaultConfig, Class<?>... resourceOrProviderClasses){
setupLogging();
VertxOptions options = new VertxOptions();
options.setWarningExceptionTime(Long.MAX_VALUE);
vertx = Vertx.vertx(options);
AppGlobals.init();
AppGlobals.get().setVertx(vertx);
// Propagate the Resteasy context on RxJava
RxJavaHooks.setOnSingleCreate(new ResteasyContextPropagatingOnSingleCreateAction());
return loadConfig(defaultConfig)
.flatMap(config -> {
return setupPlugins()
.flatMap(v -> setupTemplateRenderers())
.flatMap(v -> setupResteasy(resourceOrProviderClasses))
.flatMap(deployment -> {
setupSwagger(deployment);
return setupVertx(config, deployment);
});
});
}
示例6: setupHooks
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
private void setupHooks() {
RxJavaHooks.setOnObservableStart(new Func2<Observable, OnSubscribe, OnSubscribe>() {
@Override
public OnSubscribe call(Observable observable, OnSubscribe onSubscribe) {
incrementActiveSubscriptionsCount();
return onSubscribe;
}
});
RxJavaHooks.setOnObservableSubscribeError(new Func1<Throwable, Throwable>() {
@Override
public Throwable call(Throwable throwable) {
decrementActiveSubscriptionsCount();
return throwable;
}
});
RxJavaHooks.setOnObservableReturn(new Func1<Subscription, Subscription>() {
@Override
public Subscription call(Subscription subscription) {
decrementActiveSubscriptionsCount();
return subscription;
}
});
}
示例7: apply
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxAndroidPlugins.getInstance().reset();
RxAndroidPlugins.getInstance().registerSchedulersHook(rxAndroidSchedulersHook);
RxJavaHooks.reset();
RxJavaHooks.setOnIOScheduler(rxJavaSchedulerHook);
RxJavaHooks.setOnNewThreadScheduler(rxJavaSchedulerHook);
RxJavaHooks.setOnComputationScheduler(rxJavaSchedulerHook);
base.evaluate();
RxAndroidPlugins.getInstance().reset();
RxJavaHooks.reset();
}
};
}
示例8: apply
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxJavaHooks.reset();
RxJavaHooks.setOnIOScheduler(mMockSchedulerFunc);
RxJavaHooks.setOnNewThreadScheduler(mMockSchedulerFunc);
RxAndroidPlugins.getInstance().reset();
RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
base.evaluate();
RxJavaHooks.reset();
RxAndroidPlugins.getInstance().reset();
}
};
}
示例9: apply
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxJavaHooks.reset();
RxAndroidPlugins.getInstance().reset();
RxJavaHooks.setOnIOScheduler(scheduler -> Schedulers.immediate());
RxJavaHooks.setOnNewThreadScheduler(scheduler -> Schedulers.immediate());
RxJavaHooks.setOnComputationScheduler(scheduler -> Schedulers.immediate());
RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
base.evaluate();
RxJavaHooks.reset();
RxAndroidPlugins.getInstance().reset();
}
};
}
示例10: setup
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
@Before
public void setup() throws Exception {
dockerContainers.rabbit().assertUp();
rabbitTcpPort = dockerContainers.rabbit().tcpPort();
rabbitAdminPort = dockerContainers.rabbit().adminPort();
log.infoWithParams("****** Rabbit broker is up and running *****");
BrokerAddresses addresses = new BrokerAddresses("amqp://localhost:" + rabbitTcpPort);
channelFactory = new DefaultChannelFactory(addresses, connectionSettings);
consumerFactory = new DefaultConsumerFactory(channelFactory, consumeSettings);
publisherFactory = new DefaultPublisherFactory(channelFactory, publishSettings);
httpClient = new AsyncHttpClient();
messagesSeen.clear();
createQueues(channelFactory, inputQueue, new Exchange(inputExchange));
publisher = publisherFactory.createPublisher();
RxJavaHooks.setOnIOScheduler(null);
}
示例11: setUp
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
@Before
public void setUp() {
BaseActivity activity = Robolectric.setupActivity(UserActivity.class);
// ユースケースのモック
User user = new User();
user.id = 1L;
user.login = "user";
GetUserUseCase getUserUseCase = mock(GetUserUseCase.class);
when(getUserUseCase.run("user")).thenReturn(Single.just(user));
when(getUserUseCase.run("wrong")).thenReturn(Single.error(new Throwable("error")));
// イベントバスのモック
eventBus = mock(EventBus.class);
// ビューモデルの作成
userViewModel = new UserActivityViewModel(activity, getUserUseCase, eventBus);
// subscribeOnのスレッドをioからimmediateに変更
RxJavaHooks.setOnIOScheduler(scheduler -> Schedulers.immediate());
}
示例12: registerRxJavaIdlingResources
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
private void registerRxJavaIdlingResources() {
RxIdlingResource rxIdlingResource = new RxIdlingResource();
RxJavaHooks.setOnObservableStart((observable, onSubscribe) -> {
rxIdlingResource.incrementActiveSubscriptionsCount();
return onSubscribe;
});
RxJavaHooks.setOnObservableReturn(subscription -> {
rxIdlingResource.decrementActiveSubscriptionsCount();
return subscription;
});
RxJavaHooks.setOnObservableSubscribeError(throwable -> {
rxIdlingResource.decrementActiveSubscriptionsCount();
return throwable;
});
Espresso.registerIdlingResources(rxIdlingResource);
}
示例13: testB
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
@Test
public void testB() {
AtomicBoolean isRxJavaHooksSetOnErrorCalled = new AtomicBoolean(false);
RxJavaHooks.setOnError(throwable -> {
isRxJavaHooksSetOnErrorCalled.set(true);
});
TestSubscriber<Object> ts = new TestSubscriber<>();
createProblematicObservable().subscribe(ts);
ts.awaitTerminalEvent();
// We assert that RxJavaHooks.onError was *not* called, because Observable.onErrorResumeNext
// should have been called.
Assert.assertFalse(isRxJavaHooksSetOnErrorCalled.get());
ts.assertNoErrors();
ts.assertValue("OK");
ts.assertCompleted();
}
示例14: emitComplete
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
void emitComplete() {
set(STATE_TERMINATED);
try {
if (!isUnsubscribed()) {
subscriber.onCompleted();
}
} catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
RxJavaHooks.getOnError().call(e);
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
RxJavaHooks.getOnError().call(t);
}
}
示例15: emitError
import rx.plugins.RxJavaHooks; //导入依赖的package包/类
void emitError(Throwable t) {
set(STATE_TERMINATED);
if (!isUnsubscribed()) {
try {
subscriber.onError(t);
} catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
RxJavaHooks.getOnError().call(e);
} catch (Throwable inner) {
Exceptions.throwIfFatal(inner);
RxJavaHooks.getOnError().call(new CompositeException(t, inner));
}
}
}