android - Convert AsyncTask to RxAndroid -
i have following method post response ui using otto , asynctask
.
private static void ongetlateststorycollectionsuccess(final storycollection storycollection, final bus bus) { new asynctask<void, void, void>() { @override protected void doinbackground(void... params) { bus.post(new lateststorycollectionresponse(storycollection)); return null; } }.execute(); }
i need convert asynctask
rxjava
using rxandroid library.
don't use .create() use .defer()
observable<file> observable = observable.defer(new func0<observable<file>>() { @override public observable<file> call() { file file = downloadfile(); return observable.just(file); } });
to know more details see https://speakerdeck.com/dlew/common-rxjava-mistakes
Comments
Post a Comment