you may separate this or combined to caller class. public interface AsyncResponse { void processFinish(String output); } public AsyncResponse callback = null; public MyAsyncTask(AsyncResponse callback){ this.callback = callback; } @Override protected void doInBackground(Params ...) { ... } @Override protected void onPostExecute(String result) { callback.processFinish(result); } } new MyAsyncTask(myCallback).execute();
you may separate this or combined to caller class. public interface AsyncResponse { void processFinish(String output); } public AsyncResponse callback = null; public MyAsyncTask(AsyncResponse callback){ this.callback = callback; } @Override protected void doInBackground(Params ...) { ... } @Override protected void onPostExecute(String result) { callback.processFinish(result); } } new MyAsyncTask(myCallback).execute();
you may separate this or combined to caller class. public interface AsyncResponse { void processFinish(String output); } public AsyncResponse callback = null; public MyAsyncTask(AsyncResponse callback){ this.callback = callback; } @Override protected void doInBackground(Params ...) { ... } @Override protected void onPostExecute(String result) { callback.processFinish(result); } } new MyAsyncTask(myCallback).execute();
you may separate this or combined to caller class. public interface AsyncResponse { void processFinish(String output); } public AsyncResponse callback = null; public MyAsyncTask(AsyncResponse callback){ this.callback = callback; } @Override protected void doInBackground(Params ...) { ... } @Override protected void onPostExecute(String result) { callback.processFinish(result); } } new MyAsyncTask(myCallback).execute();
subscriber.onNext(“Hello!”); subscriber.onNext(“From the Upside Down!”); subscriber.onComplete(); }); At the beginning, you should *probably* never use this.
Observable, you get a reference to the subscription. ▸ You may or may not need to hold onto this subscription. ▸ If you are done listening for events from the Observable, you should call “unsubscribe” on the Subscription reference.
we can convert from String to Integer, can we convert from one object to another? ▸ Yes. ▸ Question 2 - Can we convert one Observable to another? ▸ Let’s find out…
the Observable will operate. ▸ If not specified, defaults to the thread on which the Observable was created. ▸ Declared only once. ▸ If used multiple times, first usage wins.
the Observer will operate. ▸ If not specified, defaults to the thread on which subscribeOn was assigned ▸ Declared as many times as needed ▸ If used multiple times, affects downstream operations.
lifecycle ▸ How do we continue a subscription on configuration change? ▸ Be mindful if you have a long running operation and your activity/fragment is terminated.
to the Android Lifecycle myObservable.compose(bindUntilEvent(ActivityEvent.Destroy)) .subscribe( … ) (Note: Fragments/Activities must extend RxActivity/ RxAppCompatActivity or RxFragment)