Retrofit - Analysis of the internal structure and working principle of RxjavaCallAdapterFactory in retrofit 11

callAdapter


RxJavaCallAdapterFactory


[Theory]
Call<T> : First get a Call object, and then use the Call object to execute our specific HTTP request, and Retrofit calls this Call request, which is actually the Call in OKHTTP, but it is called package.
converter : To get the data returned by the server, you need to call the converter data converter to convert the objects we need.
java object

[implementation]
1. Implement Factory: Implement the abstract class of Factory in the interface of CallAdapter.
2 Register CallAdapter: Register our CallAdapter with Retrofit.
3 After registration, get the specific CallAdapter by calling the Factory.get method.
4 Finally, call the adapter method to finally convert our Call request into an object type suitable for each platform.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325907710&siteId=291194637