Open QianChaoha opened 6 years ago
可以升级adapter-java到2.x、rxlifecylce到2.x:
api 'io.reactivex.rxjava2:rxjava:2.2.7'
api 'io.reactivex.rxjava2:rxandroid:2.1.1'
//api 'com.trello:rxlifecycle:1.0'
//api 'com.trello:rxlifecycle-components:1.0'
api 'com.trello.rxlifecycle2:rxlifecycle:2.2.2'
api 'com.trello.rxlifecycle2:rxlifecycle-android-lifecycle:2.2.2'
/*网络请求*/
api 'com.squareup.retrofit2:retrofit:2.5.0'
//api 'com.squareup.retrofit2:adapter-rxjava:2.5.0'
api 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
api 'com.squareup.retrofit2:converter-scalars:2.5.0'
api 'com.squareup.retrofit2:converter-gson:2.5.0'
然后用下面这个绑定生命周期即可:
observable.compose(AndroidLifecycle.createLifecycleProvider(activityOrFragment).<String>bindToLifecycle())
可以不用,已经优化了,https://github.com/wzgiceman/Cpx_model 已经更新可以去这里查看
我用ReactNative怎么办,人家要用ReactActivity。而且有的组件只是个View而已,获取activity麻烦,只有context