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

how to get response in retrofit while using rxAndroid?

我目前正在关注此 tutorial。虽然我已成功采用 rxAndroid 来避免由回收视图引起的 Exception,但我正在从改造中丢失 Response 对象。

我最初的请求是由...

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

// then call it by
userRepo.get().enqueue(callback)

其中 callback 会有 Response 对象,但是在将上面的转换为...

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
                            }
                    )
            )

我基本上无法从回调中访问 Response。我确实有点需要状态码。知道怎么做吗?

谢谢

而不是Single<T>,有它return Single<Response<T>>