本文介绍了Rxandroid SubscribeOn和ObserveOn之间的区别是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在学习Rx-java和Rxandroid2,我只是觉得在SubscribeOn和ObserveOn之间的主要区别是什么。

I am just learning Rx-java and Rxandroid2 and I am just confused what is the major difference between in SubscribeOn and ObserveOn.

推荐答案

SubscribeOn指定Observable将在其上运行的Scheduler。
ObserveOn指定观察者将观察此Observable的Scheduler。

SubscribeOn specify the Scheduler on which an Observable will operate.ObserveOn specify the Scheduler on which an observer will observe this Observable.

所以基本上SubscribeOn主要是在后台线程上订阅(执行)(你不想要在等待observable时阻止UI线程)在ObserveOn中你想在主线程上观察结果......

So basically SubscribeOn is mostly subscribed (executed) on a background thread ( you do not want to block the UI thread while waiting for the observable) and also in ObserveOn you want to observe the result on a main thread...

如果你熟悉AsyncTask那么SubscribeOn类似于doInBackground方法和ObserveOn到onPostExecute ......

If you are familiar with AsyncTask then SubscribeOn is similar to doInBackground method and ObserveOn to onPostExecute...

这篇关于Rxandroid SubscribeOn和ObserveOn之间的区别是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 12:44