Convert AsyncTask to RxAndroid

后端 未结 3 1748
北恋
北恋 2021-02-04 03:02

I have the following method to post response to UI using otto and AsyncTask.

private static void onGetLatestStoryCollectionSuccess(final StoryColle         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-04 03:43

    Don't use .create() but use .defer()

    Observable observable = Observable.defer(new Func0>() {
      @Override public Observable call() {
    
        File file = downloadFile();
    
        return Observable.just(file);
      }
    });
    

    to know more details see https://speakerdeck.com/dlew/common-rxjava-mistakes

提交回复
热议问题