记录使用Retrofit2+RxJava2心得

首先吐槽一下,我快GG了...
那么我自己都快GG了,就不能让后边的朋友们再吃苦了!(当然了 自己摸索一遍印象总是会更深的 总是依靠别人的成果 始终不是自己的成果 俗话说得好“授之以鱼不如授之以渔”嘛~)
所以,接下来的总结都是我个人的总结,当然也参考了(很多*N)的资料以及前辈的总结
我会详细的记录下我遇到的难点、出现的问题、以及解决方法。
但是由于精力有限所以故不能所有API都展示出来,请谅解!

计划

1.使用Retrofit2请求网络数据
2.使用RxJava2编写Demo
3.整合Retrofit2+RxJava2
4.整合Retrofit2+RxJava2+MVP

使用

一、使用Retrofit2请求网络数据

1.导入依赖(所有的依赖截止到2018.1.4都是最新的)

    implementation "io.reactivex.rxjava2:rxjava:2.1.8"
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    /*
        converter-gson是Retrofit到Gson进行转换的库
        如果你使用的是Jackson,替换为如下依赖即可
        compile 'com.squareup.retrofit2:converter-jackson:2.3.0'
    */
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    //adapter-rxjava2是Retrofit到RxJava进行转换的库
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    implementation 'com.google.code.gson:gson:2.8.2'

2.生成实体类
这里使用的是AS插件GsonFromat生成
详细请参考:


你可能感兴趣的:(记录使用Retrofit2+RxJava2心得)