RxJava asynchronous request implementation method, rxjava asynchronous request
RxJava asynchronous request implementation method.
Observable. just (""). map (new Func1
> () {@ Override public List
Call (String s) {List
List = new ArrayList <> (); // The logic for executing time-consuming operations is written here. list is the returned result set return list ;}}). subscribeOn (Schedulers. io ()). observeOn (AndroidSchedulers. mainThread ()). subscribe (new Action1
> () {@ Override public void call (List
List) {// The list here is the result set returned after the above request, which can be processed }});
The initial source is "". Later, we use the map operator to request data and convert the String-type Observable to List. Type Observable.
The result is correct, but I don't know why I always feel that this is not the correct method.