本文整理匯總了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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
});
}
示例9: decorateScheduledActionWithIdlingResource
import io.reactivex.plugins.RxJavaPlugins; //導入方法依賴的package包/類
private void decorateScheduledActionWithIdlingResource(CountingIdlingResource countingIdlingResource) {
RxJavaPlugins.setScheduleHandler(oldAction -> () -> {
try {
countingIdlingResource.increment();
oldAction.run();
} finally {
countingIdlingResource.decrement();
}
});
}
示例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);
}
示例11: initializePlugins
import io.reactivex.plugins.RxJavaPlugins; //導入方法依賴的package包/類
public static void initializePlugins() {
LOG.debug("Initializing ReactiveX plugins");
RxJavaPlugins.setScheduleHandler((runnable) -> new WayfRunnable(runnable));
}