danielgomezrico danielgomezrico - 5 months ago 79
Android Question

RxJavaPlugins.getInstance is deprecated

I override my schedulers for testing with:

RxJavaPlugins.getInstance().registerSchedulersHook(object : RxJavaSchedulersHook() {
override fun getIOScheduler() = Schedulers.immediate()
override fun getComputationScheduler() = Schedulers.immediate()
override fun getNewThreadScheduler() = Schedulers.immediate()


But docs says:

Deprecated use the static methods of RxJavaHooks.

How can I override those schedulers using


Release notes for 1.1.7 contain code samples how to do that in java. Small excerpt for setting computation scheduler:

   RxJavaHooks.setOnIOScheduler { Schedulers.immediate() }
   RxJavaHooks.setOnComputationScheduler { Schedulers.immediate() }
   RxJavaHooks.setOnNewThreadScheduler { Schedulers.immediate() }

There is also

By default, all RxJavaHooks delegate to the original RxJavaPlugins callbacks so if you have hooks the old way, they still work. RxJavaHooks.reset() resets to this delegation and RxJavaHooks.clear() clears all hooks (i.e., everything becomes a pass-through hook).