Skip to content

Instantly share code, notes, and snippets.

@nasserkhosravi
Created August 19, 2022 19:10
Show Gist options
  • Save nasserkhosravi/296bebbb46596d812dd0ad3b481c437f to your computer and use it in GitHub Desktop.
Save nasserkhosravi/296bebbb46596d812dd0ad3b481c437f to your computer and use it in GitHub Desktop.
Interfacing Rx Schedulers
import io.reactivex.Scheduler
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
class DefaultSchedulerProvider : SchedulerProvider {
override fun io(): Scheduler = Schedulers.io()
override fun ui(): Scheduler = AndroidSchedulers.mainThread()
override fun computation(): Scheduler = Schedulers.computation()
override fun trampoline(): Scheduler = Schedulers.trampoline()
override fun newThread(): Scheduler = Schedulers.newThread()
}
interface SchedulerProvider {
fun io(): Scheduler
fun ui(): Scheduler
fun computation(): Scheduler
fun trampoline(): Scheduler
fun newThread(): Scheduler
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment