Retrofit+Rxjava的简单使用 2019-03-18


一、引言

最近一直在学习Android框架,学习了Retrofit+Rxjava的简单使用特此纪录下。


二、导入依赖

//retrofit

implementation 'com.squareup.retrofit2:retrofit:2.4.0'

implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

implementation 'com.squareup.retrofit2:adapter-rxjava:2.4.0'

//rxjava

implementation 'io.reactivex.rxjava2:rxjava:2.1.17'

implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'


Retrofit+Rxjava的简单使用 2019-03-18_第1张图片
依赖


三、 Retrofit

创建一个接口:

ApiService

ApiService


Retrofit+Rxjava的简单使用 2019-03-18_第2张图片
初始化

四、 创建观察者


Retrofit+Rxjava的简单使用 2019-03-18_第3张图片
观察者


五、 总结

这只是Retrofit+Rxjava结合的走下大体流程,接下来几篇将详细的介绍Retrofit和Rxjava

你可能感兴趣的:(Retrofit+Rxjava的简单使用 2019-03-18)