Hi Valentin, I am wondering how your applySchedulers() looks like with RXJava 2 :)
Stoycho Andreev
11

Hi Stoycho Andreev ,

It’s actually really straighforward. I have utility functions depending on whether or not I am dealing with an Observable, Single, or Completable:

public static <T> ObservableTransformer<T, T> applySchedulers() {
return upstream -> upstream.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}

public static <T> SingleTransformer<T, T> applySchedulersSingle(SchedulerProvider schedulerProvider) {
return upstream -> upstream.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}

public static CompletableTransformer applySchedulersCompletable(SchedulerProvider schedulerProvider) {
return upstream -> upstream.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}

Hope this helps :)

Show your support

Clapping shows how much you appreciated Valentin Hinov’s story.