In RxJava/RxAndroid, you often need to enforce the threading especially when doing network operations, for example:
Single.fromCallable(/*download*/)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
Support the single is inside a static method or a method, which one of the following makes more sense:
public static Single<File> download(URL url) {
return Single.fromCallable(/*download*/);
}
public static Single<File> download(URL url) {
return Single.fromCallable(/*download*/)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
}
Basically, whose responsibility it is to enforce the threading, the callers' or the callee's and why?