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


Java RxJavaHooks类代码示例

本文整理汇总了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));
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:BodyOnSubscribe.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:ResultOnSubscribe.java

示例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;
    });
}
 
开发者ID:OHoussein,项目名称:Android-Show-Reader,代码行数:17,代码来源:RxIdlingResource.java

示例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();
        }
    };
}
 
开发者ID:OHoussein,项目名称:Android-Show-Reader,代码行数:20,代码来源:RxSchedulersOverrideRule.java

示例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);
						});
			});
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:24,代码来源:Server.java

示例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;
        }
    });
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:26,代码来源:RxIdlingResource.java

示例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();
        }
    };
}
 
开发者ID:Plastix,项目名称:RxSchedulerRule,代码行数:21,代码来源:RxSchedulerRule.java

示例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();
        }
    };
}
 
开发者ID:ArturVasilov,项目名称:RxLoader,代码行数:20,代码来源:RxSchedulersTestRule.java

示例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();
        }
    };
}
 
开发者ID:AnironGlass,项目名称:MVP-Boilerplate,代码行数:21,代码来源:RxSchedulersRule.java

示例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);
}
 
开发者ID:meltwater,项目名称:rxrabbit,代码行数:19,代码来源:RxRabbitTests.java

示例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());
}
 
开发者ID:kobakei,项目名称:Anago,代码行数:22,代码来源:UserActivityViewModelTest.java

示例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);
}
 
开发者ID:BartoszJarocki,项目名称:android-starter,代码行数:21,代码来源:StarterTestRunner.java

示例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();
}
 
开发者ID:akarnokd,项目名称:akarnokd-misc,代码行数:21,代码来源:ProblemTestCase.java

示例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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:CallArbiter.java

示例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));
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:CallArbiter.java


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