I have the following method to post response to UI using otto and AsyncTask
.
private static void onGetLatestStoryCollectionSuccess(final StoryColle
In your case you can use fromCallable
. Less code and automatic onError
emissions.
Observable observable = Observable.fromCallable(new Callable() {
@Override
public File call() throws Exception {
File file = downloadFile();
return file;
}
});
Using lambdas:
Observable observable = Observable.fromCallable(() -> downloadFile());