8000 GitHub - oyyj42/SimpleRxTask: A SimpleRxTask, base on RxJava2, take plase of AsyncTask . (一个基于RxJava2的SimpleRxTask,为取代AsyncTask)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A SimpleRxTask, base on RxJava2, take plase of AsyncTask . (一个基于RxJava2的SimpleRxTask,为取代AsyncTask)

Notifications You must be signed in to change notification settings

oyyj42/SimpleRxTask

Repository files navigation

SimpleRxTask

A SimpleRxTask, base on RxJava2, take plase of AsyncTask of Android.

Improvements:

  1. Safe. Catch exceptions internal Compare with AsyncTask.

  2. Rubust. Cancel() in main/worker thread while AsyncTask sometimes has bugs with cancel().

  3. Consistent. Don't need to care about different implement of AsyncTask in Android 2.3 ~ 8.0

  4. Simple. like : SimpleRxTask<PROGRESS, RESULT> , instead of AsyncTask<Params,Progress,Result>, because you can pass Params in when onPrepare()

Usage:


	dependencies {
	        compile 'com.github.oyyj42:SimpleRxTaskDemo:v1.0.1'
	}
	

demo:


       mTask = new SimpleRxTask<Integer, String>() {

            @Override
            protected void onPrepare() {

            }

            @Override
            protected String doInBackground() throws Exception {
                return "hello";
            }

            @Override
            protected void onProgress(Integer integer) {
  
         
5505
   }

            @Override

            protected void onSuccess(String result) {
                Log.i(TAG, "result:" + result);
            }

            @Override
            protected void onCancelled() {
   
            }
        };

        mTask.start();

About

A SimpleRxTask, base on RxJava2, take plase of AsyncTask . (一个基于RxJava2的SimpleRxTask,为取代AsyncTask)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

0