當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。