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


Java RxJavaSchedulersHook类代码示例

本文整理汇总了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();
		}
	});
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:SignInPresenterTest.java

示例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();
		}
	});
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:RepositoriesPresenterTest.java

示例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) {
    }
}
 
开发者ID:ArturVasilov,项目名称:AndroidArchitecture,代码行数:24,代码来源:RxUtils.java

示例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);
        }
    };
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:19,代码来源:RxHelper.java

示例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);
}
 
开发者ID:konglinghai123,项目名称:zhai,代码行数:27,代码来源:RxUnitTestTools.java

示例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);
}
 
开发者ID:klisly,项目名称:fingerpoetry-android,代码行数:27,代码来源:RxUnitTestTools.java

示例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);
    }
  };
}
 
开发者ID:vert-x3,项目名称:vertx-rx,代码行数:24,代码来源:RxHelper.java

示例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;
        }
    });
}
 
开发者ID:futurice,项目名称:android-rxmvvmdi,代码行数:29,代码来源:RxTest.java

示例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();
        }
    });
}
 
开发者ID:AndruByrne,项目名称:rx-daggered-robogradler,代码行数:28,代码来源:RoboTestRunner.java

示例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();
}
 
开发者ID:alexandrubordei,项目名称:goomusic,代码行数:14,代码来源:TestSongService.java

示例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);
}
 
开发者ID:LuoboDcom,项目名称:ZZShow,代码行数:29,代码来源:NewsModuleApiImplTest.java

示例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();
        }
    });
}
 
开发者ID:konifar,项目名称:annict-android,代码行数:10,代码来源:RxHelper.java

示例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();
        }
    });
}
 
开发者ID:fedepaol,项目名称:TestingRxJava,代码行数:12,代码来源:RxJavaTestRunner.java

示例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());
}
 
开发者ID:vert-x3,项目名称:vertx-rx,代码行数:37,代码来源:SchedulerTest.java

示例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;
    }
  }
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:13,代码来源:Rx.java


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