本文整理汇总了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));
}