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


Java RxJavaPlugins.setScheduleHandler方法代码示例

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


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

示例1: directScheduleOnceUsesHook

import io.reactivex.plugins.RxJavaPlugins; //导入方法依赖的package包/类
@Test
public void directScheduleOnceUsesHook() {
    final CountingRunnable newCounter = new CountingRunnable();
    final AtomicReference<Runnable> runnableRef = new AtomicReference<>();
    RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {
        @Override public Runnable apply(Runnable runnable) {
            runnableRef.set(runnable);
            return newCounter;
        }
    });

    CountingRunnable counter = new CountingRunnable();
    scheduler.scheduleDirect(counter);

    // Verify our runnable was passed to the schedulers hook.
    assertSame(counter, runnableRef.get());

    runUiThreadTasks();
    // Verify the scheduled runnable was the one returned from the hook.
    assertEquals(1, newCounter.get());
    assertEquals(0, counter.get());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:HandlerSchedulerTest.java

示例2: directScheduleOnceWithDelayUsesHook

import io.reactivex.plugins.RxJavaPlugins; //导入方法依赖的package包/类
@Test
public void directScheduleOnceWithDelayUsesHook() {
    final CountingRunnable newCounter = new CountingRunnable();
    final AtomicReference<Runnable> runnableRef = new AtomicReference<>();
    RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {
        @Override public Runnable apply(Runnable runnable) {
            runnableRef.set(runnable);
            return newCounter;
        }
    });

    CountingRunnable counter = new CountingRunnable();
    scheduler.scheduleDirect(counter, 1, MINUTES);

    // Verify our runnable was passed to the schedulers hook.
    assertSame(counter, runnableRef.get());

    idleMainLooper(1, MINUTES);
    runUiThreadTasks();
    // Verify the scheduled runnable was the one returned from the hook.
    assertEquals(1, newCounter.get());
    assertEquals(0, counter.get());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:HandlerSchedulerTest.java

示例3: workerScheduleOnceUsesHook

import io.reactivex.plugins.RxJavaPlugins; //导入方法依赖的package包/类
@Test
public void workerScheduleOnceUsesHook() {
    final CountingRunnable newCounter = new CountingRunnable();
    final AtomicReference<Runnable> runnableRef = new AtomicReference<>();
    RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {
        @Override public Runnable apply(Runnable runnable) {
            runnableRef.set(runnable);
            return newCounter;
        }
    });

    Worker worker = scheduler.createWorker();

    CountingRunnable counter = new CountingRunnable();
    worker.schedule(counter);

    // Verify our runnable was passed to the schedulers hook.
    assertSame(counter, runnableRef.get());

    runUiThreadTasks();
    // Verify the scheduled runnable was the one returned from the hook.
    assertEquals(1, newCounter.get());
    assertEquals(0, counter.get());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:HandlerSchedulerTest.java

示例4: workerScheduleOnceWithDelayUsesHook

import io.reactivex.plugins.RxJavaPlugins; //导入方法依赖的package包/类
@Test
public void workerScheduleOnceWithDelayUsesHook() {
    final CountingRunnable newCounter = new CountingRunnable();
    final AtomicReference<Runnable> runnableRef = new AtomicReference<>();
    RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {
        @Override public Runnable apply(Runnable runnable) {
            runnableRef.set(runnable);
            return newCounter;
        }
    });

    Worker worker = scheduler.createWorker();

    CountingRunnable counter = new CountingRunnable();
    worker.schedule(counter, 1, MINUTES);

    // Verify our runnable was passed to the schedulers hook.
    assertSame(counter, runnableRef.get());

    idleMainLooper(1, MINUTES);
    runUiThreadTasks();
    // Verify the scheduled runnable was the one returned from the hook.
    assertEquals(1, newCounter.get());
    assertEquals(0, counter.get());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:HandlerSchedulerTest.java

示例5: workerUnsubscriptionDuringSchedulingCancelsScheduledAction

import io.reactivex.plugins.RxJavaPlugins; //导入方法依赖的package包/类
@Test
public void workerUnsubscriptionDuringSchedulingCancelsScheduledAction() {
    final AtomicReference<Worker> workerRef = new AtomicReference<>();
    RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {
        @Override public Runnable apply(Runnable runnable) {
            // Purposefully unsubscribe in an asinine point after the normal unsubscribed check.
            workerRef.get().dispose();
            return runnable;
        }
    });

    Worker worker = scheduler.createWorker();
    workerRef.set(worker);

    CountingRunnable counter = new CountingRunnable();
    worker.schedule(counter);

    runUiThreadTasks();
    assertEquals(0, counter.get());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:HandlerSchedulerTest.java

示例6: directSchedulePeriodicallyUsesHookOnce

import io.reactivex.plugins.RxJavaPlugins; //导入方法依赖的package包/类
@Test @Ignore("Implementation delegated to default RxJava implementation")
public void directSchedulePeriodicallyUsesHookOnce() {
    final CountingRunnable newCounter = new CountingRunnable();
    final AtomicReference<Runnable> runnableRef = new AtomicReference<>();
    RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {
        @Override public Runnable apply(Runnable runnable) {
            runnableRef.set(runnable);
            return newCounter;
        }
    });

    CountingRunnable counter = new CountingRunnable();
    scheduler.schedulePeriodicallyDirect(counter, 1, 1, MINUTES);

    // Verify our action was passed to the schedulers hook.
    assertSame(counter, runnableRef.get());
    runnableRef.set(null);

    idleMainLooper(1, MINUTES);
    runUiThreadTasks();
    // Verify the scheduled action was the one returned from the hook.
    assertEquals(1, newCounter.get());
    assertEquals(0, counter.get());

    // Ensure the hook was not called again when the runnable re-scheduled itself.
    assertNull(runnableRef.get());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:HandlerSchedulerTest.java

示例7: workerSchedulePeriodicallyUsesHookOnce

import io.reactivex.plugins.RxJavaPlugins; //导入方法依赖的package包/类
@Test @Ignore("Implementation delegated to default RxJava implementation")
public void workerSchedulePeriodicallyUsesHookOnce() {
    Worker worker = scheduler.createWorker();

    final CountingRunnable newCounter = new CountingRunnable();
    final AtomicReference<Runnable> runnableRef = new AtomicReference<>();
    RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {
        @Override public Runnable apply(Runnable runnable) {
            runnableRef.set(runnable);
            return newCounter;
        }
    });

    CountingRunnable counter = new CountingRunnable();
    worker.schedulePeriodically(counter, 1, 1, MINUTES);

    // Verify our action was passed to the schedulers hook.
    assertSame(counter, runnableRef.get());
    runnableRef.set(null);

    idleMainLooper(1, MINUTES);
    runUiThreadTasks();
    // Verify the scheduled action was the one returned from the hook.
    assertEquals(1, newCounter.get());
    assertEquals(0, counter.get());

    // Ensure the hook was not called again when the runnable re-scheduled itself.
    assertNull(runnableRef.get());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:HandlerSchedulerTest.java

示例8: enableTracing

import io.reactivex.plugins.RxJavaPlugins; //导入方法依赖的package包/类
public static void enableTracing(final Tracer tracer) {

    RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {
      @Override
      public Runnable apply(Runnable runnable) {
        return new TracingRunnable(runnable, tracer);
      }
    });
  }
 
开发者ID:opentracing-contrib,项目名称:java-rxjava,代码行数:10,代码来源:TracingRxJava2Utils.java

示例9: decorateScheduledActionWithIdlingResource

import io.reactivex.plugins.RxJavaPlugins; //导入方法依赖的package包/类
private void decorateScheduledActionWithIdlingResource(CountingIdlingResource countingIdlingResource) {
    RxJavaPlugins.setScheduleHandler(oldAction -> () -> {
        try {
            countingIdlingResource.increment();
            oldAction.run();
        } finally {
            countingIdlingResource.decrement();
        }
    });
}
 
开发者ID:sumio,项目名称:RxJavaEspressoSample,代码行数:11,代码来源:ActivityCountingIdlingResourceTest.java

示例10: setUp

import io.reactivex.plugins.RxJavaPlugins; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
    RxIdlingResource rxIdlingResource = new RxIdlingResource();
    Espresso.registerIdlingResources(rxIdlingResource);
    RxJavaPlugins.setScheduleHandler(rxIdlingResource);

}
 
开发者ID:charafau,项目名称:TurboChat,代码行数:8,代码来源:MessageActivityWriteMessageTest.java

示例11: initializePlugins

import io.reactivex.plugins.RxJavaPlugins; //导入方法依赖的package包/类
public static void initializePlugins() {
    LOG.debug("Initializing ReactiveX plugins");

    RxJavaPlugins.setScheduleHandler((runnable) -> new WayfRunnable(runnable));
}
 
开发者ID:Atypon-OpenSource,项目名称:wayf-cloud,代码行数:6,代码来源:WayfReactivexConfig.java


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