将自定义转换器与 rxandroid Completable 一起使用

Using custom converter with rxandroid Completable

我在使用 rxandroid 改造时遇到问题。 我创建了一个自定义转换器,如下所示:

class CustomResponseConverter<T>(private val converter: Converter<ResponseBody, *>): Converter<ResponseBody, T> {

    override fun convert(value: ResponseBody): T? {
        // custom convert response here
    }
}

当我像这样返回 Single 时一切正常:

@GET("route")
fun simpleFetch(): Single<FetchData>

但是当我尝试像这样返回 Completable 时:

@GET("route")
fun simpleFetch(): Completable

我发现 convert 函数没有被调用。请帮忙。

提前致谢。

对于 运行 和我有同样情况的任何人,显然根据改装团队 here:

Using Completable bypasses all converters, yes, and simply closes the response body so it is consumed. Since there is nowhere for the converted body to go with a Completable, there is no need to call it and perform conversion.

所以我想在这种情况下我们将继续使用 Single