Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin 使用rxAndroid时如何在改造中获得响应?_Kotlin_Rx Java_Retrofit2_Rx Android - Fatal编程技术网

Kotlin 使用rxAndroid时如何在改造中获得响应?

Kotlin 使用rxAndroid时如何在改造中获得响应?,kotlin,rx-java,retrofit2,rx-android,Kotlin,Rx Java,Retrofit2,Rx Android,我现在正在关注这个。虽然我成功地采用了rxAndroid以避免由回收视图引起的异常,但我正在丢失改装后的响应对象 我最初的请求是由 interface UserRepo { @GET("user") fun get(): Call<User> } // then call it by userRepo.get().enqueue(callback) 我基本上无法从回调中访问响应。我确实需要身份代码。知道怎么做吗 感谢而不是单曲,让它返回单曲而不是单曲,让它返回单曲

我现在正在关注这个。虽然我成功地采用了rxAndroid以避免由回收视图引起的
异常
,但我正在丢失改装后的
响应
对象

我最初的请求是由

interface UserRepo {
    @GET("user")
    fun get(): Call<User>
}

// then call it by
userRepo.get().enqueue(callback)
我基本上无法从回调中访问
响应
。我确实需要身份代码。知道怎么做吗

感谢而不是
单曲
,让它返回
单曲

而不是
单曲
,让它返回
单曲

interface UserRepo {
    @GET("user")
    fun get(): Single<User>
}

// then call it by
mCompositeDisposable.add(userRepo.get()
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(
                            { success -> 
                                // todo success 
                            },
                            { error ->
                                // todo error
                            }
                    )
            )