Last active
February 28, 2018 10:45
-
-
Save alorma/7386182c697f747d9d2a91c885781a64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun configureRxThreading() { | |
RxJavaPlugins.reset() | |
val immediate = object : Scheduler() { | |
override fun scheduleDirect(run: Runnable, delay: Long, unit: TimeUnit): Disposable { | |
return super.scheduleDirect(run, 0, unit) | |
} | |
override fun createWorker(): Worker { | |
return ExecutorScheduler.ExecutorWorker(Executor { it.run() }) | |
} | |
} | |
RxJavaPlugins.setInitIoSchedulerHandler { immediate } | |
RxJavaPlugins.setInitComputationSchedulerHandler { immediate } | |
RxJavaPlugins.setInitNewThreadSchedulerHandler { immediate } | |
RxJavaPlugins.setInitSingleSchedulerHandler { immediate } | |
RxAndroidPlugins.setInitMainThreadSchedulerHandler { immediate } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
init { | |
configureRxThreading() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment