gpt4 book ai didi

android - 我们应该为 Rxjava3 使用哪个 rxjava3 改造适配器

转载 作者:行者123 更新时间:2023-12-03 13:24:50 24 4
gpt4 key购买 nike

我正在使用 RxJava3 和改造,但我无法为 RxJava3 获得 rxjava3 改造适配器。

最佳答案

现在有一个 2.9.0 版本的官方改造实现:

只需使用您创建改造客户端的适配器:

val rxAdapter = RxJava3CallAdapterFactory.create()
retrofit = Retrofit.Builder().baseUrl(baseUrl)
.addConverterFactory(MoshiConverterFactory.create(moshi))
.client(httpClient)
.addCallAdapterFactory(rxAdapter).build()

并在您的 build.gradle 中包含 RxAdapter 依赖项:
implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'

https://github.com/square/retrofit/blob/master/CHANGELOG.md#version-290-2020-05-20

同样来自文档:

Unlike the RxJava 1 and RxJava 2 adapters, the RxJava 3 adapter's create() method will produce asynchronous HTTP requests by default. For synchronous requests use createSynchronous() and for synchronous on a scheduler use createWithScheduler(..)

关于android - 我们应该为 Rxjava3 使用哪个 rxjava3 改造适配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60606941/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com