本文整理汇总了Java中rx.plugins.RxJavaSchedulersHook类的典型用法代码示例。如果您正苦于以下问题:Java RxJavaSchedulersHook类的具体用法?Java RxJavaSchedulersHook怎么用?Java RxJavaSchedulersHook使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RxJavaSchedulersHook类属于rx.plugins包,在下文中一共展示了RxJavaSchedulersHook类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
presenter = new SignInPresenter();
presenter.setViewState(signInViewState);
RxJavaPlugins.getInstance().reset();
RxJavaPlugins.getInstance().registerSchedulersHook(new RxJavaSchedulersHook() {
@Override
public Scheduler getIOScheduler() {
return Schedulers.immediate();
}
});
RxAndroidPlugins.getInstance().reset();
RxAndroidPlugins.getInstance().registerSchedulersHook(new RxAndroidSchedulersHook() {
@Override
public Scheduler getMainThreadScheduler() {
return Schedulers.immediate();
}
});
}
示例2: setUp
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
presenter = new RepositoriesPresenter();
presenter.setViewState(repositoriesViewState);
RxJavaPlugins.getInstance().reset();
RxJavaPlugins.getInstance().registerSchedulersHook(new RxJavaSchedulersHook() {
@Override
public Scheduler getIOScheduler() {
return Schedulers.immediate();
}
});
RxAndroidPlugins.getInstance().reset();
RxAndroidPlugins.getInstance().registerSchedulersHook(new RxAndroidSchedulersHook() {
@Override
public Scheduler getMainThreadScheduler() {
return Schedulers.immediate();
}
});
}
示例3: setupTestSchedulers
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
public static void setupTestSchedulers() {
try {
RxJavaPlugins.getInstance().registerSchedulersHook(new RxJavaSchedulersHook() {
@Override
public Scheduler getIOScheduler() {
return Schedulers.immediate();
}
@Override
public Scheduler getNewThreadScheduler() {
return Schedulers.immediate();
}
});
RxAndroidPlugins.getInstance().registerSchedulersHook(new RxAndroidSchedulersHook() {
@Override
public Scheduler getMainThreadScheduler() {
return Schedulers.immediate();
}
});
} catch (IllegalStateException ignored) {
}
}
示例4: schedulerHook
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
public static RxJavaSchedulersHook schedulerHook(Context context) {
return new RxJavaSchedulersHook() {
@Override
public Scheduler getComputationScheduler() {
return scheduler(context);
}
@Override
public Scheduler getIOScheduler() {
return blockingScheduler(context.owner());
}
@Override
public Scheduler getNewThreadScheduler() {
return scheduler(context);
}
};
}
示例5: openRxTools
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
/**
* 把异步变成同步,方便测试
*/
public static void openRxTools() {
if (isInitRxTools) {
return;
}
isInitRxTools = true;
RxAndroidSchedulersHook rxAndroidSchedulersHook = new RxAndroidSchedulersHook() {
@Override
public Scheduler getMainThreadScheduler() {
return Schedulers.immediate();
}
};
RxJavaSchedulersHook rxJavaSchedulersHook = new RxJavaSchedulersHook() {
@Override
public Scheduler getIOScheduler() {
return Schedulers.immediate();
}
};
RxAndroidPlugins.getInstance().registerSchedulersHook(rxAndroidSchedulersHook);
RxJavaPlugins.getInstance().registerSchedulersHook(rxJavaSchedulersHook);
}
示例6: openRxTools
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
/**
* 把异步变成同步,方便测试
*/
public static void openRxTools() {
if (isInitRxTools) {
return;
}
isInitRxTools = true;
RxAndroidSchedulersHook rxAndroidSchedulersHook = new RxAndroidSchedulersHook() {
@Override
public Scheduler getMainThreadScheduler() {
return Schedulers.immediate();
}
};
RxJavaSchedulersHook rxJavaSchedulersHook = new RxJavaSchedulersHook() {
@Override
public Scheduler getIOScheduler() {
return Schedulers.immediate();
}
};
RxAndroidPlugins.getInstance().registerSchedulersHook(rxAndroidSchedulersHook);
RxJavaPlugins.getInstance().registerSchedulersHook(rxJavaSchedulersHook);
}
示例7: schedulerHook
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
/**
* Create a scheduler hook for a {@link Context} object, the {@link rx.plugins.RxJavaSchedulersHook#getIOScheduler()}
* uses a blocking scheduler.
*
* @param context the context object
* @return the scheduler hook
*/
public static RxJavaSchedulersHook schedulerHook(Context context) {
return new RxJavaSchedulersHook() {
@Override
public Scheduler getComputationScheduler() {
return scheduler(context);
}
@Override
public Scheduler getIOScheduler() {
return blockingScheduler(context.owner());
}
@Override
public Scheduler getNewThreadScheduler() {
return scheduler(context);
}
};
}
示例8: initSchedulers
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
@BeforeClass
public static void initSchedulers() {
RxJavaPlugins.getInstance().reset();
RxJavaPlugins.getInstance().registerSchedulersHook(new RxJavaSchedulersHook() {
@Override
public Scheduler getComputationScheduler() {
return delegatingComputationScheduler;
}
@Override
public Scheduler getIOScheduler() {
return delegatingIoScheduler;
}
@Override
public Scheduler getNewThreadScheduler() {
return delegatingNewThreadScheduler;
}
});
RxAndroidPlugins.getInstance().reset();
RxAndroidPlugins.getInstance().registerSchedulersHook(new RxAndroidSchedulersHook() {
@Override
public Scheduler getMainThreadScheduler() {
return delegatingMainScheduler;
}
});
}
示例9: RoboTestRunner
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
public RoboTestRunner(Class<?> klass) throws InitializationError {
super(klass);
RxJavaTestPlugins.resetPlugins();
RxJavaPlugins.getInstance().registerSchedulersHook(new RxJavaSchedulersHook(){
@Override
public Scheduler getComputationScheduler() {
return Schedulers.immediate();
}
@Override
public Scheduler getIOScheduler() {
return Schedulers.immediate();
}
@Override
public Scheduler getNewThreadScheduler() {
return Schedulers.immediate();
}
});
RxAndroidPlugins.getInstance().reset();
RxAndroidPlugins.getInstance().registerSchedulersHook(new RxAndroidSchedulersHook(){
@Override
public Scheduler getMainThreadScheduler() {
return Schedulers.immediate();
}
});
}
示例10: prepareFsSongStore
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
@Before
public void prepareFsSongStore() {
vertx = Vertx.vertx();
//need this for our use of rxjava.
RxJavaSchedulersHook hook = RxHelper.schedulerHook(vertx);
rx.plugins.RxJavaPlugins.getInstance().registerSchedulersHook(hook);
URL url = this.getClass().getResource("/A/A/A/TRAAAAW128F429D538.json");
String root = Paths.get(url.getFile()).getParent().getParent().getParent().getParent().toString();
System.setProperty(FileSystemSongStore.ROOT_PATH_PROPERTY, root);
songStore = new FileSystemSongStore();
}
示例11: testLoadNews
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
@Test
public void testLoadNews() throws Exception {
System.out.println("-- 1.testLoadNews --");
// 让Schedulers.io()返回当前线程
RxJavaPlugins.getInstance().registerSchedulersHook(new RxJavaSchedulersHook() {
@Override
public Scheduler getIOScheduler() {
return Schedulers.immediate();
}
});
moduleApi.loadNews(new RequestCallBack<List<NewsSummary>>() {
@Override
public void beforeRequest() {
}
@Override
public void success(List<NewsSummary> data) {
}
@Override
public void onError(String errorMsg) {
}
}, ApiConstants.NETEASE_TYPE_OTHER, ApiConstants.NETEASE_ID_GAME, 0);
assertEquals(1,1);
}
示例12: setUpRx
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
public static void setUpRx() {
RxJavaPlugins.getInstance().reset();
RxJavaPlugins.getInstance().registerSchedulersHook(new RxJavaSchedulersHook() {
@Override
public Scheduler getIOScheduler() {
return Schedulers.immediate();
}
});
}
示例13: RxJavaTestRunner
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
public RxJavaTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
RxJavaTestPlugins.resetPlugins();
RxJavaPlugins.getInstance().registerSchedulersHook(new RxJavaSchedulersHook() {
@Override
public Scheduler getIOScheduler() {
return Schedulers.immediate();
}
});
}
示例14: testSchedulerHook
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
private void testSchedulerHook(Supplier<ContextScheduler> scheduler) throws Exception {
RxJavaPlugins plugins = RxJavaPlugins.getInstance();
AtomicInteger scheduled = new AtomicInteger();
AtomicInteger called = new AtomicInteger();
CountDownLatch latchCalled = new CountDownLatch(1);
plugins.registerSchedulersHook(new RxJavaSchedulersHook() {
@Override
public Action0 onSchedule(Action0 action) {
scheduled.incrementAndGet();
return () -> {
action.call();
called.getAndIncrement();
latchCalled.countDown();
};
}
});
ContextScheduler scheduler2 = scheduler.get();
Scheduler.Worker worker = scheduler2.createWorker();
assertEquals(0, scheduled.get());
assertEquals(0, called.get());
CountDownLatch latch = new CountDownLatch(1);
AtomicInteger workerScheduledVal = new AtomicInteger();
AtomicInteger workerCalledVal = new AtomicInteger();
worker.schedule(() -> {
workerScheduledVal.set(scheduled.get());
workerCalledVal.set(called.get());
latch.countDown();
}, 0, TimeUnit.SECONDS);
awaitLatch(latch);
awaitLatch(latchCalled);
assertEquals(1, scheduled.get());
assertEquals(1, called.get());
assertEquals(1, workerScheduledVal.get());
assertEquals(0, workerCalledVal.get());
}
示例15: trySchedulerHook
import rx.plugins.RxJavaSchedulersHook; //导入依赖的package包/类
private void trySchedulerHook(final Map<String, Executor> executors) {
RxJavaPlugins plugins = RxJavaPlugins.getInstance();
try {
plugins.registerSchedulersHook(new ExecSchedulerHook(executors));
} catch (IllegalStateException ex) {
// there is a scheduler hook already, check if ours and ignore the exception
RxJavaSchedulersHook hook = plugins.getSchedulersHook();
if (!(hook instanceof ExecSchedulerHook)) {
throw ex;
}
}
}